this is most of the code that i am useing to get the numbers from the file.
As you can see, i am already useing strings, but it is still reading the
full line. I would like it to read one number at a time.
FileReader theFile;
BufferedReader fileIn;
String oneLine;
int [] unsort = new int [10];
int n = 3;
int r = 1;
try{
theFile = new FileReader( fileName);
fileIn = new BufferedReader ( theFile );
while ( (oneLine = fileIn.readLine()) !=null){
unsort[r] = Integer.parseInt(oneLine);
Your parsing is looking for spaces. Why dont you use oneLine.charAt(index)
and typecast it as an int.
"lindsey" <zave4@aol.com> wrote:
>
>this is most of the code that i am useing to get the numbers from the file.
> As you can see, i am already useing strings, but it is still reading the
>full line. I would like it to read one number at a time.
>
> FileReader theFile;
> BufferedReader fileIn;
> String oneLine;
> int [] unsort = new int [10];
> int n = 3;
> int r = 1;
> try{
> theFile = new FileReader( fileName);
> fileIn = new BufferedReader ( theFile );
> while ( (oneLine = fileIn.readLine()) !=null){
> unsort[r] = Integer.parseInt(oneLine);
>
> }
> System.out.println( unsort[1]);
> }
> catch(Exception e){
> { System.out.println (e); }
> }