Revision: 10171
          http://sourceforge.net/p/languagetool/code/10171
Author:   dnaber
Date:     2013-06-02 11:04:00 +0000 (Sun, 02 Jun 2013)
Log Message:
-----------
simplify code, make file encoding explicit

Modified Paths:
--------------
    
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/synthesis/SynthesizerTools.java

Modified: 
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/synthesis/SynthesizerTools.java
===================================================================
--- 
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/synthesis/SynthesizerTools.java
 2013-06-01 08:16:54 UTC (rev 10170)
+++ 
trunk/languagetool/languagetool-core/src/main/java/org/languagetool/synthesis/SynthesizerTools.java
 2013-06-02 11:04:00 UTC (rev 10171)
@@ -18,11 +18,10 @@
  */
 package org.languagetool.synthesis;
 
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.util.ArrayList;
+import java.util.Scanner;
 
 public class SynthesizerTools {
   
@@ -30,33 +29,19 @@
     // static methods only, no public constructor
   }
 
-  public static ArrayList<String> loadWords(final InputStream file) throws 
IOException {
+  public static ArrayList<String> loadWords(final InputStream stream) throws 
IOException {
     final ArrayList<String> set = new ArrayList<String>();
-    InputStreamReader isr = null;
-    BufferedReader br = null;
+    final Scanner scanner = new Scanner(stream, "UTF-8");
     try {
-      isr = new InputStreamReader(file);
-      br = new BufferedReader(isr);
-      String line;
-      
-      while ((line = br.readLine()) != null) {
-        line = line.trim();
-        if (line.length() < 1) {
+      while (scanner.hasNextLine()) {
+        final String line = scanner.nextLine().trim();
+        if (line.length() < 1 || line.charAt(0) == '#') {  // ignore empty 
lines and comments
           continue;
         }
-        if (line.charAt(0) == '#') {      // ignore comments
-          continue;
-        }        
         set.add(line);
       }
-      
     } finally {
-      if (br != null) {
-        br.close();
-      }
-      if (isr != null) {
-        isr.close();
-      }
+      scanner.close();
     }
     return set;
   }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits

Reply via email to