Убедись что метод getFileContent возвращает пустую строку, если метод run не запускался.
package com.javarush.task.task16.task1630;
import java.io.*;
import java.util.Scanner;
public class Solution {
public static String firstFileName;
public static String secondFileName;
static {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
firstFileName = reader.readLine();
secondFileName = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
systemOutPrintln(firstFileName);
systemOutPrintln(secondFileName);
}
public static void systemOutPrintln(String fileName) throws Exception {
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() throws Exception;
void join() throws InterruptedException;
void start();
}
public static class ReadFileThread extends Thread implements ReadFileInterface{
String fullFileName;
@Override
public void setFileName(String fullFileName) {
this.fullFileName = fullFileName;
}
@Override
public String getFileContent() throws Exception {
if (this.fullFileName == null)
{
return "";
}
else {
return fullFileName;
}
}
@Override
public void run() {
try {
FileReader file = new FileReader(getFileContent());
Scanner scan = new Scanner(file);
int i = 1;
while (scan.hasNextLine()) {
System.out.print(" " + scan.nextLine());
i++;
}
file.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}