Member Avatar for chris53825

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?

Member Avatar for chris53825

Nevermind, got it to work!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.