loading an integer data file into an integer array
Joined: Oct 10, 2005
In preparation for a computing contest here in So. Florida, I'm trying to figure out a simple method to read a numerical data file into an array so that I can then massage the numbers in various ways. This has turned into a daunting task because of unicode issues. The data file looks like this
where 0 signals an end of file. I can get the file contents to print out just peachy (in the standard output, bottom output box, using JGrasp), but I cannot find a simple way to load this data file AS INTEGERS into an integer array. I load the array as follows:
What loads is as follows:
This has been printed out with the following:
I understand that what is being loaded is unicode for 5  followed by the equivalent of a new-line [13 10] followed by unicode for the next 10 integers, et cetera. What I would like to do is to populate the integer array with the integers from the data file.
Joined: Feb 07, 2005
I would do something like this.
The numbers are stored in a file called numbers.txt.
Indeed, a blank line is not a number. So you need to test for that so you can skip the blank lines that apparently appear in the file. Before calling Integer.valueOf, you need to check if the String is "".