где я накосячил?
package com.javarush.task.task19.task1915;
import java.io.*;
/*
Дублируем текст
*/
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) throws IOException {
PrintStream ps = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream stream = new PrintStream(baos);
System.setOut(stream);
testString.printSomething();
String result = baos.toString();
System.setOut(ps);
System.out.println(result);
//___________________________
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileOutputStream fileOutputStream = new FileOutputStream(reader.readLine());
fileOutputStream.write(baos.toByteArray());
System.out.println(baos.toString());
reader.close();
fileOutputStream.close();
}
public static class TestString {
public void printSomething() {
System.out.println("it's a text for testing");
}
}
}