-
files
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); }
}
-
Re: files
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); }
> }
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks