wie schreibe ich in die konsole und in die datei?
package de.codegym.task.task19.task1915;
import java.io.*;
/*
Text duplizieren
*/
public class Solution {
public static TestString testString = new TestString();
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
FileOutputStream outStream = new FileOutputStream(reader.readLine());
PrintStream console = System.out;
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream print = new PrintStream(out);
System.setOut(print);
testString.printSomething();
System.setOut(console);
// outStream.write(testString.printSomething());
reader.close();
outStream.close();
}
public static class TestString {
public void printSomething() {
System.out.println("This is text for testing");
}
}
}