• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading from a text file  RSS feed

 
Ciara O Brien
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Im new to Java and am having alot of trouble with this one problem, if you could help it would be much appriciated.
I am writing a program to display the resistance curve of a thermistor.
The problem is that the x and y points are read in from a Dat file. The Dat file will be in the form of
Temp(�C) RValue(Ohms)
-40 46,080
-20 14,990
0 5,720
20 2,439
25 2,000
40 1,142
The values on the left are the X-coordinates and on the right are the Y-coordinates. I have tried using the StringTokenizer class but to no avail.
Any help would be greatly appreciated.
 
Jason Kretzer
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:

this will get you the first line. Use a while loop after that to get the rest and store them somewhere. Note this will return Strings and you will have to use Integer.parseInt(String) to convert them to ints.
Good luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!