/* LanguageTool, a natural language style checker 
 * Copyright (C) 2008 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool.synthesis;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class SynthesizerTools {
  
  private SynthesizerTools() {
    // static methods only, no public constructor
  }

  public static ArrayList<String> loadWords(final InputStream file) throws IOException {
    final ArrayList<String> set = new ArrayList<String>();
    InputStreamReader isr = null;
    BufferedReader br = null;
    try {
      isr = new InputStreamReader(file);
      br = new BufferedReader(isr);
      String line;
      
      while ((line = br.readLine()) != null) {
        line = line.trim();
        if (line.length() < 1) {
          continue;
        }
        if (line.charAt(0) == '#') {      // ignore comments
          continue;
        }        
        set.add(line);
      }
      
    } finally {
      if (br != null) {
        br.close();
      }
      if (isr != null) {
        isr.close();
      }
    }
    return set;
  }

}

@@ -895,39 +895,8 @@
 s;%0A%0A
-import java.io.BufferedReader;%0A
 impo
@@ -951,42 +951,8 @@
 am;%0A
-import java.io.InputStreamReader;%0A
 impo
@@ -974,16 +974,42 @@
 rayList;
+%0Aimport java.util.Scanner;
 %0A%0Apublic
@@ -1185,20 +1185,22 @@
 tStream 
-file
+stream
 ) throws
@@ -1281,247 +1281,156 @@
     
-InputStreamReader isr = null;%0A    BufferedReader br = null;%0A    try %7B%0A      isr = new InputStreamReader(file);%0A      br = new BufferedReader(isr
+final Scanner scanner = new Scanner(stream, %22UTF-8%22
 );%0A    
- 
- String line;%0A      %0A      while ((line = br.readLine()) != null) %7B%0A        line = l
+try %7B%0A      while (scanner.hasNextLine()) %7B%0A        final String line = scanner.nextL
 ine
+()
 .tri
@@ -1467,54 +1467,12 @@
  %3C 1
-) %7B%0A          continue;%0A        %7D%0A        if (
+ %7C%7C 
 line
@@ -1491,20 +1491,16 @@
 = '#') %7B
-    
   // ign
@@ -1503,16 +1503,32 @@
  ignore 
+empty lines and 
 comments
@@ -1557,24 +1557,16 @@
        %7D
-        
 %0A       
@@ -1593,15 +1593,8 @@
   %7D%0A
-      %0A
     
@@ -1615,89 +1615,14 @@
     
-if (br != null) %7B%0A        br.close();%0A      %7D%0A      if (isr != null) %7B%0A        is
+scanne
 r.cl
@@ -1628,24 +1628,16 @@
 lose();%0A
-      %7D%0A
     %7D%0A  

simplify code, make file encoding explicit