Валидатор не пропускает:
Убедись что метод getFileContent возвращает пустую строку, если метод run не запускался.
Все работает, но просит доп проверку, не пойму для чего.
package com.javarush.task.task16.task1630;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
public class Solution {
public static String firstFileName;
public static String secondFileName;
//add your code here - добавьте код тут
static{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
firstFileName = reader.readLine();
secondFileName = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
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();
//add your code here - добавьте код тут
System.out.println(f.getFileContent());
}
public interface ReadFileInterface {
void setFileName(String fullFileName);
String getFileContent();
void join() throws InterruptedException;
void start();
}
//add your code here - добавьте код тут
public static class ReadFileThread extends Thread implements ReadFileInterface{
private String fullFileName;
private String content = null;
@Override
public void run() {
String result = "";
FileInputStream fis = null;
try {
fis = new FileInputStream(fullFileName);
String s = null;
BufferedReader r = new BufferedReader(new InputStreamReader(fis));
while((s = r.readLine()) != null) {
result += s + " ";
}
} catch (IOException e) {
e.printStackTrace();
}
content = result;
}
@Override
public void setFileName(String fullFileName) {
this.fullFileName = fullFileName;
}
@Override
public String getFileContent() {
return content;
}
}
}