.
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;
//add your code here - добавьте код тут
static{
try{
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
firstFileName = r.readLine();
secondFileName = r.readLine();
}
catch (IOException 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();
//add your code here - добавьте код тут
f.join();
System.out.println(f.getFileContent());
}
// public static ReadFileThread extends Thread{
// public void Run(){
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;
public void setFileName(String fullFileName){
this.fullFileName = fullFileName;
}
// public void join() throws InterruptedException{
// }
// public void start(){
// }
public String getFileContent(){
if (Thread.currentThread().isInterrupted())
return null;
else
return fullFileName;
}
public void run(){
BufferedReader read = null;
try{
read = new BufferedReader(new FileReader(fullFileName));
//x = read.readLine();
while (true){
String s = read.readLine();
if (s.isEmpty() || s == null){
read.close();
System.out.println(s + " ");
return;
}
}
}
catch(Exception e) {}
// read.close();
}
}
}