private ArrayList < ArrayList < String > > parseString ( String text ) { ArrayList < ArrayList < String >> result = new ArrayList < ArrayList < String > > ( ) ; StringTokenizer linetoken = new StringTokenizer ( text , "\n" ) ; StringTokenizer token ; String current ; while ( linetoken . hasMoreTokens ( ) ) { current = linetoken . nextToken ( ) ; if ( current . contains ( "," ) ) { token = new StringTokenizer ( current , "," ) ; } else { token = new StringTokenizer ( current ) ; } ArrayList < String > line = new ArrayList < String > ( ) ; while ( token . hasMoreTokens ( ) ) { line . add ( token . nextToken ( ) ) ; } result . add ( line ) ; } return result ; }
turns the clipboard into a list of tokens each array list is a line each string in the list is a token in the line