// File handling
/*
Write a Java program that reads a file and
displays the file on the screen, with a line number before each line.
*/
import java.io.*;
class FileLineDisplay
{
public
static void main(String as[]) throws IOException
{
FileReader
fr = new FileReader("ipt.txt");
BufferedReader
br = new BufferedReader(fr);
int
linecount=1;
while(true)
{
String
str = br.readLine();
if(str==null)
break;
System.out.print(linecount+"
"+str+"\n");
linecount++;
}
fr.close();
}
}
No comments:
Post a Comment
Don't be a silent reader...
Leave your comments...
Anu