wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Reading file into an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading file into an array" Watch "Reading file into an array" New topic

Reading file into an array

Yafet Negussie

Joined: Mar 17, 2012
Posts: 4
Hi all
I'm trying to read list of numbers from a file to an array. The numbers are read fine, but I'm unable to put them into an array. I cannot see what I'm doing wrong. Can you help please? Here is my code
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if it's not working because this line prints out 0's
look at the order of your lines of code

starts at
index = 0,
then numbers[0] = ...
then index++
so, in this first time through
is actually

or, it's printing out the value of the next numbers[]

Yafet Negussie

Joined: Mar 17, 2012
Posts: 4
Thank you Michael
that was indeed the problem.
Don't get me started about those stupid light bulbs.
subject: Reading file into an array
Similar Threads
Looping through BufferedReader Class
Store BufferedReader Data into an ArrayList
Creating my First Object
Parsing a text file