private static List<String> extractTextItems(){
  List<String> retList=new ArrayList<String>();
  SFileChooser chooser=new SFileChooser(getDictionaryDirectory(),"text file","txt");
  chooser.addExtension("rtf");
  File theFile=chooser.showOpenDialog();
  if (theFile != null) {
    Scanner scanner;
    try {
      scanner=new Scanner(new FileReader(theFile));
      try {
        while (scanner.hasNextLine()) {
          Scanner lineScan=new Scanner(scanner.nextLine());
          while (lineScan.hasNext()) {
            String word=lineScan.next();
            retList.add(word);
          }
        }
      }
  finally {
        scanner.close();
        setDictionaryDirectory(chooser.getCurrentLocation());
      }
    }
 catch (    FileNotFoundException e) {
      e.printStackTrace();
    }
  }
  return retList;
}

private static List < String > extractTextItems ( ) { List < String > retList = new ArrayList < String > ( ) ; SFileChooser chooser = new SFileChooser ( getDictionaryDirectory ( ) , "text file" , "txt" ) ; chooser . addExtension ( "rtf" ) ; File theFile = chooser . showOpenDialog ( ) ; if ( theFile != null ) { Scanner scanner ; try { scanner = new Scanner ( new FileReader ( theFile ) ) ; try { while ( scanner . hasNextLine ( ) ) { Scanner lineScan = new Scanner ( scanner . nextLine ( ) ) ; while ( lineScan . hasNext ( ) ) { String word = lineScan . next ( ) ; retList . add ( word ) ; } } } finally { scanner . close ( ) ; setDictionaryDirectory ( chooser . getCurrentLocation ( ) ) ; } } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } } return retList ; }
extract all the text items from a file .
