read text from a file output to the console
Import Java.io.filenotfoundexception;import Java.io.filereader;import java.io.ioexception;//read the text in a file, output to the console// The character text is read, so you can use a character stream to manipulate public class Filereaderdemos {public static void main (string[] args) {//TODO auto-generated method s Tubfilereader fr = Null;try {fr = new FileReader ("c:\\users\\administrator\\desktop\\ Test folder \ \ new text document. txt");// Call the Read method output to the console int len = 0;try {while (len = Fr.read ())!=-1) {System.out.print (char) len);} catch (IOException e) {//TOD O auto-generated catch Blocke.printstacktrace ();}} catch (FileNotFoundException e) {//TODO auto-generated catch Blocke.printstacktrace ();} Finally{try {fr.close ();} catch (IOException e) {//TODO auto-generated catch Blocke.printstacktrace ();}}}
To run the program:
Dark Horse Programmer--io--Read text output from a file to the console