X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FWriteBuffer.java;h=1ddd42f15062a895740045ad147c25d5a3a56f87;hb=2fc669d88306d563fc9c899d8d91b25d591692ea;hp=c68264ebb583523283039adb9a70a313e207b6dd;hpb=863fc804a6496c920a2b2045913c45f938bb646c;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/engine/WriteBuffer.java b/src/com/hughes/android/dictionary/engine/WriteBuffer.java index c68264e..1ddd42f 100644 --- a/src/com/hughes/android/dictionary/engine/WriteBuffer.java +++ b/src/com/hughes/android/dictionary/engine/WriteBuffer.java @@ -14,8 +14,8 @@ package com.hughes.android.dictionary.engine; -import java.io.OutputStream; import java.io.IOException; +import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; @@ -27,22 +27,20 @@ public class WriteBuffer extends PipedOutputStream { try { pipe = new PipedInputStream(this, size); buffer = new byte[BLOCK_SIZE]; - writeThread = new Thread(new Runnable() { - public void run() { - int read; - try { - while ((read = pipe.read(buffer)) > 0) - { - out.write(buffer, 0, read); - out.flush(); - } - } catch (IOException e) { - System.out.println("Error writing to file " + e); + writeThread = new Thread(() -> { + int read; + try { + while ((read = pipe.read(buffer)) > 0) + { + out.write(buffer, 0, read); + out.flush(); } - try { - out.close(); - } catch (IOException e) {} + } catch (IOException e) { + System.out.println("Error writing to file " + e); } + try { + out.close(); + } catch (IOException e) {} }); writeThread.start(); } catch (IOException e) {} @@ -61,5 +59,5 @@ public class WriteBuffer extends PipedOutputStream { Thread writeThread; OutputStream out; PipedInputStream pipe; - byte buffer[]; + byte[] buffer; }