User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,967 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,740 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 350 | Replies: 1 | Solved
Reply
Join Date: Sep 2007
Posts: 12
Reputation: chris53825 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chris53825 chris53825 is offline Offline
Newbie Poster

Question Tokenizer help

  #1  
Nov 17th, 2007
Hey guys,

I'm trying to read from a file and put each column into it's corresponding array.
% P_ID     CPU_burst    I/O_burst     Priority
0           10              4             2
1            8              2             1
2           12              0             5


while ((Line=myInput.readLine()) != null) {
        		
        		 StringTokenizer s = new StringTokenizer(Line);
        		 
                 //System.out.println(Line);
                
                 pid[counter]= Integer.parseInt(s.nextToken().toString());
                 cpu[counter]= Integer.parseInt(s.nextToken().toString());
                 io[counter]= Integer.parseInt(s.nextToken().toString());
                 prior[counter]= Integer.parseInt(s.nextToken().toString());
                  
                 counter++;
                     
                      
                      
                      
  }  

This does not work, I'm thinking that the s.nexttoken is continuing past each line read in.
Any suggestions?
Last edited by chris53825 : Nov 17th, 2007 at 3:30 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 12
Reputation: chris53825 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
chris53825 chris53825 is offline Offline
Newbie Poster

Re: Tokenizer help

  #2  
Nov 17th, 2007
Nevermind, got it to work!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 9:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC