aspose file tools*
The moose likes Beginning Java and the fly likes help reading in file of integers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help reading in file of integers" Watch "help reading in file of integers" New topic
Author

help reading in file of integers

Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
I am trying to read in a file of integers for a heap sort program. The problem I am having is that the code will only grab the second digit. If the integer is only a single digit it will throw an error on me.



Data File:

10
11
13
19
34
12
45
91
91
16
33


Output:

C:/test.txt
0
1
3
9
4
2
5
1
1
6
3

[ September 28, 2004: Message edited by: Dirk Schreckmann ]
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
try


[ September 28, 2004: Message edited by: chi Lin ]

not so smart guy still curious to learn new stuff every now and then
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
your code is wrong because in every loop you read first character in each line in file.

So, you can change your code like this :



SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
Thanks for the help everyone!
 
wood burning stoves
 
subject: help reading in file of integers