Advertisement
Guest User

Untitled

a guest
Apr 14th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.         import java.io.File;
  2.         import java.io.FileNotFoundException;
  3. import java.util.Scanner;
  4. public class manufactureArray {
  5.  
  6.     /**
  7.      * @param args
  8.      */
  9.     public static void main(String[] args) {
  10.         Scanner input= null;
  11.        
  12.         try {
  13.          input = new Scanner(new File("ManufacturersSurveySmallest.txt"));
  14.         } catch (FileNotFoundException e) {
  15.             System.err.println("ERROR - File not found");
  16.             System.exit(1);
  17.            
  18.         }        
  19.         int count=0;
  20.         while (input.hasNextLine()) {
  21.             String text = input.nextLine();
  22.             count ++;
  23.        
  24.         String [] state= new String [count];
  25.         String [] geoCode= new String [count];
  26.         String []manuArea= new String [count];
  27.         long []  workWages= new long [count];
  28.         long [] workHours= new long [count];
  29.        
  30.         parser(text, count, state, geoCode, manuArea);
  31.         }
  32.         System.out.println(count+ " records");
  33.         }
  34.     public static void parser (String text, int count, String[] state, String [] geoCode, String manuArea[]){
  35.        
  36.            
  37.     Scanner lineScanner = new Scanner (text);
  38.    
  39.     lineScanner.useDelimiter(":");
  40.    
  41.     for (int i=1; i<=count; i++){
  42.         String myState=lineScanner.next();
  43.         state[i]= myState;
  44.         String geoCodeInput= lineScanner.next();
  45.         geoCode[i]=geoCodeInput;
  46.         String manuAreaInput= lineScanner.next();
  47.         manuArea[i]= manuAreaInput;
  48.    
  49.    
  50.            
  51.     }  
  52.     System.out.printf(state[0], geoCode[0]);
  53.     }
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement