Posted: Sat Jun 14, 2008 12:03 am Post subject: File Reader!
hi!
i have a lot of trouble regarding filereader and bufferreader. naeming i don't know if the thing reads the line or character (i don't even know how it reads the line: as each character or as a line) as an int, a char, or string...
There is a question i have to write code for regarding filereader and buffer reader...
I'm very confused on this topic... oh along with the try and catch thing...that's what we've to write with filereader and bufferreader.. right?
So if one could help me with this, that would be great :
but first, the question, i really need help with this:
In the text file ?data.txt?, the first line contains an integer which indicates the number of lines that follow. You program should read each one of these lines and then output on the screen the one with the longest length.
my code:
code:
import java.io.*;
public class Test {
public static void main (String [] args){
FileReader file;
BufferedReader buffer;
String line;
int line2;
String temp;
try {
file = new FileReader ("data.txt");
buffer = new BufferedReader (file);