@Override public void thresholdNotReached() { if (chunking) { setFixedLengthStreamingMode(buffer.size()); } }
@Override public void thresholdNotReached() { if (chunking) { setFixedLengthStreamingMode(buffer.size()); } }
@Override public void thresholdNotReached() { if (chunking) { setFixedLengthStreamingMode(buffer.size()); } }
public int write(ByteBuffer src) throws IOException { int total = 0; if (buffer != null) { int pos = buffer.size(); int len = this.threshold - pos; if (len > src.remaining()) { len = src.remaining(); } src.get(buffer.getRawBytes(), pos, len); buffer.setSize(buffer.size() + len); total += len; if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } } if (cachingForRetransmission) { wrappedStream.write(src.array(), src.position(), src.remaining()); return src.remaining() + total; } return outbuf.write(src) + total; }
@Override public void write(byte[] b, int off, int len) throws IOException { if (buffer != null) { int space = threshold - buffer.size(); if (space > len) { space = len; } buffer.write(b, off, space); len -= space; off += space; if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } if (len == 0) { return; } } super.write(b, off, len); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (buffer != null) { int space = threshold - buffer.size(); if (space > len) { space = len; } buffer.write(b, off, space); len -= space; off += space; if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } if (len == 0) { return; } } super.write(b, off, len); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (buffer != null) { int space = threshold - buffer.size(); if (space > len) { space = len; } buffer.write(b, off, space); len -= space; off += space; if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } if (len == 0) { return; } } super.write(b, off, len); }
public void writeCacheTo(StringBuilder out, String charsetName) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingByteArrayOutputStream) { LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream; out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, lout.size())); } else if (currentStream instanceof ByteArrayOutputStream) { byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray(); out.append(IOUtils.newStringFromBytes(bytes, charsetName)); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024]; int x = reader.read(bytes); while (x != -1) { out.append(bytes, 0, x); x = reader.read(bytes); } } } }
@Override public void write(byte[] b, int off, int len) throws IOException { if (buffer != null) { int space = threshold - buffer.size(); if (space > len) { space = len; } buffer.write(b, off, space); len -= space; off += space; if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } if (len == 0) { return; } } super.write(b, off, len); }
public void writeCacheTo(StringBuilder out, String charsetName) throws IOException { flush(); if (inmem) { if (currentStream instanceof LoadingByteArrayOutputStream) { LoadingByteArrayOutputStream lout = (LoadingByteArrayOutputStream)currentStream; out.append(IOUtils.newStringFromBytes(lout.getRawBytes(), charsetName, 0, lout.size())); } else if (currentStream instanceof ByteArrayOutputStream) { byte[] bytes = ((ByteArrayOutputStream)currentStream).toByteArray(); out.append(IOUtils.newStringFromBytes(bytes, charsetName)); } else { throw new IOException("Unknown format of currentStream"); } } else { // read the file try (InputStream fin = createInputStream(tempFile); Reader reader = new InputStreamReader(fin, charsetName)) { char[] bytes = new char[1024]; int x = reader.read(bytes); while (x != -1) { out.append(bytes, 0, x); x = reader.read(bytes); } } } }
@Override public void write(int b) throws IOException { if (buffer != null) { buffer.write(b); if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } return; } super.write(b); }
public int copyFrom(InputStream in) throws IOException { int count = 0; while (buffer != null) { int pos = buffer.size(); int i = in.read(buffer.getRawBytes(), pos, this.threshold - pos); if (i > 0) { buffer.setSize(pos + i); if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } count += i; } else { return count; } } if (cachingForRetransmission) { count += IOUtils.copy(in, wrappedStream); } else { count += outbuf.copy(in); } return count; }
@Override public void write(int b) throws IOException { if (buffer != null) { buffer.write(b); if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } return; } super.write(b); }
@Override public void write(int b) throws IOException { if (buffer != null) { buffer.write(b); if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } return; } super.write(b); }
@Override public void write(int b) throws IOException { if (buffer != null) { buffer.write(b); if (buffer.size() >= threshold) { thresholdReached(); unBuffer(); } return; } super.write(b); }