public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { if (out == null) { synchronized (mutex) { out = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); mutex.notify(); } } while (!encoder.isCompleted()) out.produceContent(encoder); }
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); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start();
@Override public void write(final int b) throws IOException { this.lock.lock(); try { Asserts.check(!this.shutdown && !this.endOfStream, "Buffer already closed for writing"); setInputMode(); if (!this.buffer.hasRemaining()) { flushContent(); setInputMode(); } this.buffer.put((byte)b); } finally { this.lock.unlock(); } }
/** * @deprecated (4.3) use {@link #produceContent(ContentEncoder, IOControl)} */ @Override @Deprecated public int produceContent(final ContentEncoder encoder) throws IOException { return produceContent(encoder, null); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } write(b, 0, b.length); }
@Override public void reset() { if (this.shutdown) { return; } this.lock.lock(); try { clear(); this.endOfStream = false; } finally { this.lock.unlock(); } }
public void close() { shutdown(); }
this.ioctrl = ioctrl; setOutputMode(); int bytesWritten = 0; if (super.hasData()) {
@Override public void write(final int b) throws IOException { this.lock.lock(); try { Asserts.check(!this.shutdown && !this.endOfStream, "Buffer already closed for writing"); setInputMode(); if (!this.buffer.hasRemaining()) { flushContent(); setInputMode(); } this.buffer.put((byte)b); } finally { this.lock.unlock(); } }
/** * @deprecated (4.3) use {@link #produceContent(ContentEncoder, IOControl)} */ @Override @Deprecated public int produceContent(final ContentEncoder encoder) throws IOException { return produceContent(encoder, null); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } write(b, 0, b.length); }
@Override public void reset() { if (this.shutdown) { return; } this.lock.lock(); try { clear(); this.endOfStream = false; } finally { this.lock.unlock(); } }
public void close() { shutdown(); }
this.ioctrl = ioctrl; setOutputMode(); int bytesWritten = 0; if (super.hasData()) {
public void produceContent(ContentEncoder encoder, IOControl ioctrl) throws IOException { if (out == null) { synchronized (mutex) { out = new SharedOutputBuffer(8192, ioctrl, new HeapByteBufferAllocator()); mutex.notify(); } } while (!encoder.isCompleted()) out.produceContent(encoder); }
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); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start();
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } int pos = off; this.lock.lock(); try { Asserts.check(!this.shutdown && !this.endOfStream, "Buffer already closed for writing"); setInputMode(); int remaining = len; while (remaining > 0) { if (!this.buffer.hasRemaining()) { flushContent(); setInputMode(); } final int chunk = Math.min(remaining, this.buffer.remaining()); this.buffer.put(b, pos, chunk); remaining -= chunk; pos += chunk; } } finally { this.lock.unlock(); } }
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); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start(); while (!encoder.isCompleted()) ob.produceContent(encoder); }
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); } catch (InterruptedException ie) { } } ob.write(bytes, 0, nRead); } ob.writeCompleted(); } catch (IOException e) { e.printStackTrace(); } } }.start();
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } int pos = off; this.lock.lock(); try { Asserts.check(!this.shutdown && !this.endOfStream, "Buffer already closed for writing"); setInputMode(); int remaining = len; while (remaining > 0) { if (!this.buffer.hasRemaining()) { flushContent(); setInputMode(); } final int chunk = Math.min(remaining, this.buffer.remaining()); this.buffer.put(b, pos, chunk); remaining -= chunk; pos += chunk; } } finally { this.lock.unlock(); } }