i am reading from file the file is in this format
4
L 100 20 30 200
R 30 20 50 100
O 20 100 100 40
L 30 50 100 100

I'm using string tokenizer now the 4 specifies how many lines I'll have
When I read only the last 2 lines are shown pleas can any one now what is the mistake....thanks in advance.

This is the code:

Try{
Scanner scan= new Scanner(inputFile);
String N= scan.println(N):
       While(scan.hasNext())
       {
         String record=scan.nextLine();
           StringTokenizer st= new StringTokenizer(record);
         String shape=st.nextToken;
         ...and so one for the rest of the parameters
}
}

Recommended Answers

All 3 Replies

Scanner scan= new Scanner(inputFile);
String N= scan.println(N):

I don't know how you can read anything with this code - it won't compile - there is no println method in Scanner (not to mention the missing catch)

Sorry it's my fault I'm using the iPad it's difficult little pit ,,,
I ment scan.next line().
The program runs perfectly but ,,idont now there is a conceptual thing I missed

Don't let Apple hear you say that...

Anyway, I can't tell anything from the code snippet you posted, except that you don't have print statements to display the results of each step as you perform it. For example if you print each record immediately after reading it you can see if there's something wrong with your Scanner. If it's OK then move on to printing the results from the StringTokenizer, etc , until you see where the problem starts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.