import java.util.*;
import java.io.*;
public class testing
{
public static void main(String[]args)
{
int NoOfLines=0;
int i=0;
String fileName = "tingtings.txt";
String line;
String[] lines = new String[1000];
try
{
BufferedReader brStream1 = new BufferedReader(new FileReader(fileName));
while ((line = brStream1.readLine())!= null)
{
NoOfLines++;
}
while ((line = brStream1.readLine())!= null)
{
StringTokenizer aString=new StringTokenizer(line);
for(i=0; i<lines.length;i++)
{
lines[i]=aString.nextToken();
if (lines[i]==lines[i-1])
{
NoOfLines--;
i--;
}
}
}
brStream1.close();
print(lines);
System.out.println(NoOfLines);
}
catch (IOException e)
{
System.out.println("ERROR");
}
}
public static void print(String[] line)
{
for(int i = 0; i < line.length; i++)
System.out.println(line[i]);
}
}
when i run the program, it gives me null instead of the first token from each line. anyone has any idea why this is happening?