Доброго времени суток. Застрял с, в общем-то, не очень уж и сложной задачей. Вроде де бы программа делает именно то, что необходимо, но валидатор все равно не принимает. Перепробовал уже кучу разных вариантов считывания с файла и конкатенации результирующей строки. В общем не могу понять причину почему не проходит валидацию
Результат работы программы с прикрепленными файлами
123 1456 2first 2second 2third 2fourth 3first 3second
1first 1second 23456 2789 2third 2fourth 3567 3second
package com.javarush.task.task16.task1630;
import java.io.*;
/*
Последовательный вывод файлов
*/
public class Solution {
public static String firstFileName;
public static String secondFileName;
static {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
firstFileName = reader.readLine();
secondFileName = reader.readLine();
reader.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) throws InterruptedException {
systemOutPrintln(firstFileName);
systemOutPrintln(secondFileName);
}
public static void systemOutPrintln(String fileName) throws InterruptedException {
ReadFileInterface f = new ReadFileThread();
f.setFileName(fileName);
f.start();
f.join();
System.out.println(f.getFileContent());
}
public interface ReadFileInterface {
void setFileName(String fullFileName);
String getFileContent();
void join() throws InterruptedException;
void start();
}
public static class ReadFileThread extends Thread implements ReadFileInterface {
public String fullFileName;
public String fileContent;
@Override
public void setFileName(String fullFileName) {
this.fullFileName = fullFileName;
}
@Override
public String getFileContent() {
return this.fileContent;
}
@Override
public void run() {
try {
BufferedReader reader = new BufferedReader(new FileReader(fullFileName));
String line = reader.readLine();
StringBuilder builder = new StringBuilder();
while (line != null) {
builder.append(" ").append(line);
line = reader.readLine();
}
this.fileContent = builder.toString().trim();
reader.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}
}
}
}