X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FWriteBuffer.java;h=09e2655ffa88dbf19a13b1831ecc30c0a228dd15;hb=6bdac65cd6138f8660de4f248b32c35fcd748ae7;hp=a8a92eef185168099287aa064e73fc53f81be622;hpb=5a1b9f8a37d03dc675e1d895817422e9743a5b5b;p=DictionaryPC.git diff --git a/src/com/hughes/android/dictionary/engine/WriteBuffer.java b/src/com/hughes/android/dictionary/engine/WriteBuffer.java index a8a92ee..09e2655 100644 --- a/src/com/hughes/android/dictionary/engine/WriteBuffer.java +++ b/src/com/hughes/android/dictionary/engine/WriteBuffer.java @@ -20,29 +20,27 @@ import java.io.PipedInputStream; import java.io.PipedOutputStream; public class WriteBuffer extends PipedOutputStream { - static int BLOCK_SIZE = 1024 * 1024; + static int BLOCK_SIZE = 256 * 1024; public WriteBuffer(OutputStream out, int size) { assert size >= 2 * BLOCK_SIZE; this.out = out; 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; }