Reading A Text File by using Java Program
Code:
import java.io.*;
public class ReadingFromFile
{
public static void main(String[] args)
{
try
{
FileReader fr = new FileReader("D:\\Documents\\My Documents\\Mehedi.txt");
int i;
while((i=fr.read())!=-1)
{
System.out.print((char)i);
}
System.out.println("\n");
}
catch(IOException e){}
}
}
Output of program:
import java.io.*;
public class ReadingFromFile
{
public static void main(String[] args)
{
try
{
FileReader fr = new FileReader("D:\\Documents\\My Documents\\Mehedi.txt");
int i;
while((i=fr.read())!=-1)
{
System.out.print((char)i);
}
System.out.println("\n");
}
catch(IOException e){}
}
}
Output of program:
No comments