I think everything is working just fine, but one conditon isn't met, and I don't know why
package pl.codegym.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();
} 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();
System.out.println(f.getFileContents());
}
public interface ReadFileInterface {
void setFileName(String fullFileName);
String getFileContents();
void join() throws InterruptedException;
void start();
}
public static class ReadFileThread extends Thread implements ReadFileInterface{
@Override
public void run() {
getFileContents();
}
String filename;
@Override
public void setFileName(String fullFileName) {
this.filename = fullFileName;
}
public String getFileContents() {
String output = null;
try {
FileReader fr = new FileReader(filename);
BufferedReader filereader = new BufferedReader(fr);
while (filereader.ready()){
output = output + filereader.readLine() + " ";
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return output;
}
}
}