import java.io.*; import java.util.*; class ListRead { public static List readCharList(BufferedReader in) throws CharListFormatException,IOException { StringTokenizer chars; String token,str=in.readLine().trim(); List l1,l2; if(str.charAt(0)!='['||str.charAt(str.length()-1)!=']') throw new CharListFormatException(); str=str.substring(1,str.length()-1); chars = new StringTokenizer(str,","); l1=LinkedList.empty(); while(chars.hasMoreTokens()) { token=chars.nextToken(); if(token.length()!=1) throw new CharListFormatException(); l1=l1.cons(new Character(token.charAt(0))); } l2=LinkedList.empty(); while(!l1.isempty()) { l2=l2.cons(l1.head()); l1=l1.tail(); } return l2; } public static List readIntList(BufferedReader in) throws IntListFormatException,IOException { StringTokenizer ints; String token,str=in.readLine().trim(); List l1,l2; int n; if(str.charAt(0)!='['||str.charAt(str.length()-1)!=']') throw new IntListFormatException(); str=str.substring(1,str.length()-1); ints = new StringTokenizer(str,","); l1=LinkedList.empty(); while(ints.hasMoreTokens()) { token=ints.nextToken(); try { n=Integer.parseInt(token); } catch(NumberFormatException e) { throw new IntListFormatException(); } l1=l1.cons(new Integer(n)); } l2=LinkedList.empty(); while(!l1.isempty()) { l2=l2.cons(l1.head()); l1=l1.tail(); } return l2; } }