Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prj2;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.List;
- public class P2 {
- public static void main(String[] args) throws IOException {
- // TODO Auto-generated method stub
- //file not found exception //file not readable exception
- BufferedReader reader = new BufferedReader(new FileReader("p2input.txt"));
- String line = null;
- while ((line = reader.readLine()) != null) {
- System.out.println(line);
- String[] parts = line.split("\\s");
- System.out.println(parts[0]);
- List<Character> randomExpression = new ArrayList<Character>();
- for (int i=1;i<parts.length;i++)
- {
- char[] charArr=parts[i].toCharArray();
- for (int j=0; j<charArr.length;j++)
- randomExpression.add(charArr[j]);
- }
- System.out.println(randomExpression);
- }
- reader.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment