?
package com.javarush.task.task16.task1630;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Последовательный вывод файлов
*/
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 class ReadFileThread extends Thread implements ReadFileInterface {
public static String nameFiles=" ";
FileReader reader = null;
@Override
public void setFileName(String fullFileName) {
this.nameFiles=fullFileName;
}
@Override
public String getFileContent() {
return nameFiles;
}
@Override
public void run() {
try {
reader = new FileReader(getFileContent());
int c;
while((c=reader.read())!=-1){
System.out.print((char)c);
}
}
catch(IOException ex){
System.out.println(ex.getMessage());
}
interrupt();
}
}
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();
}
}