]> gitweb.fperrin.net Git - DictionaryPC.git/commitdiff
Minor code cleanup.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Mon, 13 Apr 2020 12:03:31 +0000 (14:03 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Mon, 13 Apr 2020 12:03:31 +0000 (14:03 +0200)
src/com/hughes/android/dictionary/engine/ReadAheadBuffer.java

index d4b3ab51a281ee5a177b0259530ebe8ba7c86c90..3c4c10d0aeebf2442a69fda3ba5619e94adc7c8b 100644 (file)
@@ -14,8 +14,8 @@
 
 package com.hughes.android.dictionary.engine;
 
-import java.io.InputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 
@@ -24,29 +24,26 @@ public class ReadAheadBuffer extends PipedInputStream {
     public ReadAheadBuffer(InputStream in, int size) {
         super(size);
         assert size >= 2 * BLOCK_SIZE;
-        this.in = in;
         try {
             pipe = new PipedOutputStream(this);
-            buffer = new byte[BLOCK_SIZE];
-            new Thread(new Runnable() {
-                public void run() {
-                    int read;
-                    try {
-                        while ((read = in.read(buffer)) > 0)
-                        {
-                            pipe.write(buffer, 0, read);
-                            pipe.flush();
-                        }
-                    } catch (IOException e) {}
-                    try {
-                        pipe.close();
-                    } catch (IOException e) {}
-                }
-            }).start();
         } catch (IOException e) {}
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    int read;
+                    final byte buffer[] = new byte[BLOCK_SIZE];
+                    while ((read = in.read(buffer)) > 0)
+                    {
+                        pipe.write(buffer, 0, read);
+                        pipe.flush();
+                    }
+                } catch (IOException e) {}
+                try {
+                    pipe.close();
+                } catch (IOException e) {}
+            }
+        }).start();
     }
 
-    InputStream in;
     PipedOutputStream pipe;
-    byte buffer[];
 }