I have probilem with last test. I was trying almost everything but i dont know how to resolve this.
package com.codegym.task.task16.task1630;
import java.io.*;
import java.util.Scanner;
public class Solution {
public static String firstFileName;
public static String secondFileName;
static {
{
try {
Scanner sc = new Scanner(System.in);
firstFileName = sc.nextLine();
secondFileName = sc.nextLine();
} catch (Exception 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();
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 {
String nameFile = "";
String content = "";
@Override
public void setFileName(String fullFileName) {
this.nameFile = fullFileName;
}
@Override
public String getFileContents() {
return content;
}
@Override
public void start() {
}
@Override
public void run() {
String line = "";
try {
FileReader fileReader = new FileReader(nameFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
while (bufferedReader.ready()) {
line=bufferedReader.readLine();
content = content + line+" ";
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}