List of usage examples for org.apache.http.nio.entity ContentOutputStream close
@Override public void close() throws IOException
From source file:marytts.server.http.AudioStreamNHttpEntity.java
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. */// ww w .j av a 2 s. co m public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); maryRequest.abort(); } }
From source file:marytts.tools.perceptiontest.AudioStreamNHttpEntity.java
/** * Wait for the SharedOutputBuffer to become available, write audio data to it. *//*from w w w .jav a2s . c om*/ public void run() { this.logger = MaryUtils.getLogger(Thread.currentThread().getName()); // We must wait until produceContent() is called: while (out == null) { synchronized (mutex) { try { mutex.wait(); } catch (InterruptedException e) { } } } assert out != null; ContentOutputStream outStream = new ContentOutputStream(out); try { AudioSystem.write(audio, audioType, outStream); outStream.flush(); outStream.close(); logger.info("Finished writing output"); } catch (IOException ioe) { logger.info("Cannot write output, client seems to have disconnected. ", ioe); System.err.println("Cannot write output, client seems to have disconnected." + ioe); maryRequest.abort(); } }