S
S
Sinus_3142019-02-24 22:35:31
Java
Sinus_314, 2019-02-24 22:35:31

Forgot to import something?

The simplest code, as it seemed to me, gives an error:5c72f1b9804b4042395608.png

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);
  }
}

What confuses me is that the compiler points to "new", what am I missing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Vlasov, 2019-02-24
@Sinus_314

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 question

Ask a Question

731 491 924 answers to any question