Posted: Fri Jun 13, 2008 11:54 pm Post subject: File Reader!
Hi!
i have a lot of problem with filereader and bufferreader! meaning, i don't know if the thing reads the line as a string or as a char or int... or whatever...
and also, here is a question that i have to write a code for involving using filereader and everything...
i know I did it wrong, bt i don't know how to correct it.
whenever i run it an exceptional comes up... nullpointerexception.
if one could help me regarding this situation, that would be great! thank you very mych
here's the question: 10.
In the text file ?data.txt?, the first line contains an integer which indicates the number of lines that follow. Your program should read each one of these lines and then output on the screen the one with the longest length.
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);