Sorry guys, I'm still not so good at this stuff as I should be by this level. But I need to get past this task! Don't understand that second last condition.
(And yes, partly borrowed code is pasted in kinda messy so forgive me for that! I put hours into trying to figure it out still.)
package com.codegym.task.task19.task1915;
/*
Reader Wrapper 2
*/
import java.io.*;
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String file = bufferedReader.readLine();
bufferedReader.close();
PrintStream consoleStream = System.out ;
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
FileOutputStream fileOutputStream = new FileOutputStream(file);
PrintStream stream = new PrintStream(outputStream);
System.setOut(stream);
testString.printSomething();
String result = outputStream.toString();
System.setOut(consoleStream);
outputStream.close();
fileOutputStream.close();
}
public static class TestString {
public void printSomething() {
System.out.println("This is text for testing");
}
}
}