List of usage examples for org.apache.http.nio.util SharedOutputBuffer writeCompleted
public void writeCompleted() throws IOException
From source file:marytts.server.http.TestProducingNHttpEntity.java
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { final SharedOutputBuffer ob = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); new Thread() { public void run() { try { FileInputStream fis = new FileInputStream("/Users/marc/Music/enjoytheride_feat.judytzuke_.mp3"); int nRead; byte[] bytes = new byte[4096]; while ((nRead = fis.read(bytes)) != -1) { synchronized (this) { try { wait(1);//from ww w.j a v a 2 s.com } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start(); while (!encoder.isCompleted()) ob.produceContent(encoder); }