Wednesday, 1 October 2014

JAVA PROGRAM TO READ A FILE

program:

import java.io.*;
public class FileRead {
public static void main( String[ ] args ) {
try
{
BufferedReader br = new BufferedReader (
new FileReader( "c:\\myfile.txt" ) );
String inStr = br.readLine( );
System.out.println( "The contents of the file are: " + inStr );
}
catch(IOException e)
{
//do
}
} // end of main
}


-------------------------------------------------------------------------------------------

No comments:

Post a Comment

Total Pageviews