1 Replies - 1100 Views - Last Post: 10 December 2009 - 06:01 AM Rate Topic: -----

#1 horia_nr_1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 31-October 09

read on line of integers

Post icon  Posted 10 December 2009 - 05:47 AM

:) ok. I have a question:
I have to read some data from a file.
The file contain integers 3, or 4 separated by a single space on one line. for example :
3 4 5 6
3 4 5
3 1 2 6
If there are 4 i have to create a rectangle, and if there are 3 i have to create a triangle.
How can i find if there are 3 or 4. Is in java something : while(not end of the line ){ read}?
Like in pascal while not eoln(f) do. or something like this ?
Thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: read on line of integers

#2 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3744
  • View blog
  • Posts: 17,121
  • Joined: 20-September 08

Re: read on line of integers

Posted 10 December 2009 - 06:01 AM

Read each line and do

String[] atoms = line.split("\\s+"); // number given by atoms.length


Was This Post Helpful? 1
  • +
  • -

Page 1 of 1