1 //: Testeof.java2 PackageC10;3 4 ImportJava.io.FileInputStream;5 ImportJava.io.InputStreamReader;6 7 /**8 * @time: Morning 9:55:409 * @date: April 30, 2017Ten * @auther: Skyfffire One * @version: v0.1 A */ - Public classtesteof { - Public Static voidMain (string[] args) { the Try { -String path = "./src/c10/testeof.java"; -String encoding = "UTF-8"; - +InputStreamReader ISR =NewInputStreamReader ( - NewFileInputStream (path), encoding); + intc = 0; A intlinenumber = 1; at -System.out.format ("%-4d|", linenumber++); - while((c = Isr.read ())! = 1) { -System.out.print ((Char) c); - - if(c = = ' \ n ') { inSystem.out.format ("%-4d|", linenumber++); - } to } + - isr.close (); the}Catch(Exception e) { * e.printstacktrace (); $ }Panax Notoginseng } - } the + ///:
List the contents of a file (with line number)--"Thinking in Java" essay 029