Answer the question
In order to leave comments, you need to log in
Forgot to import something?
The simplest code, as it seemed to me, gives an error:
import java.io.PrintStream;
import java.io.InputStream;
import java.io.FileOutputStream;
import java.io.*;
class SysTest{
public static void main(String[] args){
OutputStream output = new FileOutputStream("E:\\java_file\\Files_io\\fileTest.txt");
PrintStream printOut = new PrintStream(output);
System.setOut(printOut);
}
}
Answer the question
In order to leave comments, you need to log in
In java, you need to catch exceptions if the called function can throw them. Well, or forward even higher. In this case, FileNotFoundException is not handled, it must be caught and processed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question