lamiastella

p2

Jul 15th, 2014
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package prj2;
  2. import java.io.BufferedReader;
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8.  
  9. public class P2 {
  10.    
  11.  
  12.     public static void main(String[] args) throws IOException {
  13.         // TODO Auto-generated method stub
  14.         //file not found exception //file not readable exception
  15.         BufferedReader reader = new BufferedReader(new FileReader("p2input.txt"));
  16.         String line = null;
  17.         while ((line = reader.readLine()) != null) {
  18.            System.out.println(line);
  19.            String[] parts = line.split("\\s");
  20.            System.out.println(parts[0]);
  21.            List<Character> randomExpression = new ArrayList<Character>();
  22.            for (int i=1;i<parts.length;i++)
  23.            {
  24.                char[] charArr=parts[i].toCharArray();
  25.                for (int j=0; j<charArr.length;j++)
  26.                    randomExpression.add(charArr[j]);
  27.                
  28.            }
  29.            System.out.println(randomExpression);
  30.            
  31.            
  32.         }
  33.        
  34.        
  35.         reader.close();
  36.  
  37.  
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment