Hi there,
I try to get this task validated for two times and using different code but every time I got a "Time Out".
I have already ran my code on my IDE and it seems to work,
One question, the read file should be fully read before writing it on the write file?
package com.codegym.task.task19.task1906;
/*
Even characters
*/
import java.io.*;
public class Solution {
public static void main(String[] args) {
String readFileName = null;
String writeFileName = null;
try(BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))){
while(readFileName == null || readFileName.isEmpty()){
readFileName = reader.readLine();
}
while(writeFileName == null || writeFileName.isEmpty()){
writeFileName = reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
FileReader fileReader = new FileReader(readFileName);
FileWriter fileWriter = new FileWriter(writeFileName);
int count = 1;
while(fileReader.ready()){
int thisChar = fileReader.read();
if(count%2 == 0){
fileWriter.write(thisChar);
}
count++;
}
fileWriter.close();
fileReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}