Java IO stream
When you run an error, save the exception to the file
Below this instance, after running, enter the number, for the correct, if the input string, then error message, Save the wrong information
//When you run an error, save the exception to the file//below this instance, after running, enter the number, for the correct, if the input string, then error message, Save the wrong informationImportJava.io.*;ImportJava.util.*; Public classindex{ Public Static voidMain (string[] args)throwsexception{Try{ //Create a filePrintStream Zhengque =NewPrintStream ("D:/zhegnque.txt"); PrintStream Cuowu=NewPrintStream ("D:/cuowu.txt"); //using ScannersScanner input =NewScanner (system.in); intShuzi; System.setout (Zhengque); //If there is no error, save to this fileSystem.seterr (CUOWU);//If there is an error, save to this file, this function is associated with the contents of the following catch while(true) {Shuzi=Input.nextint (); System.out.println ("The number entered is:" +Shuzi); } } Catch(Exception e) {System.err.println ("Execution Error"); } }}
Java IO stream run error, save exception to file inside