Lines Matching refs:byteCount

73       @Override public void write(byte[] data, int offset, int byteCount) {
74 Buffer.this.write(data, offset, byteCount);
101 @Override public void require(long byteCount) throws EOFException {
102 if (size < byteCount) throw new EOFException();
105 @Override public boolean request(long byteCount) {
106 return size >= byteCount;
116 @Override public int read(byte[] sink, int offset, int byteCount) {
117 return Buffer.this.read(sink, offset, byteCount);
139 * Copy {@code byteCount} bytes from this, starting at {@code offset}, to
142 public Buffer copyTo(OutputStream out, long offset, long byteCount) throws IOException {
144 checkOffsetAndCount(size, offset, byteCount);
145 if (byteCount == 0) return this;
154 for (; byteCount > 0; s = s.next) {
156 int toCopy = (int) Math.min(s.limit - pos, byteCount);
158 byteCount -= toCopy;
165 /** Copy {@code byteCount} bytes from this, starting at {@code offset}, to {@code out}. */
166 public Buffer copyTo(Buffer out, long offset, long byteCount) {
168 checkOffsetAndCount(size, offset, byteCount);
169 if (byteCount == 0) return this;
171 out.size += byteCount;
180 for (; byteCount > 0; s = s.next) {
183 copy.limit = Math.min(copy.pos + (int) byteCount, copy.limit);
189 byteCount -= copy.limit - copy.pos;
201 /** Write {@code byteCount} bytes from this to {@code out}. */
202 public Buffer writeTo(OutputStream out, long byteCount) throws IOException {
204 checkOffsetAndCount(size, 0, byteCount);
207 while (byteCount > 0) {
208 int toCopy = (int) Math.min(byteCount, s.limit - s.pos);
213 byteCount -= toCopy;
231 /** Read {@code byteCount} bytes from {@code in} to this. */
232 public Buffer readFrom(InputStream in, long byteCount) throws IOException {
233 if (byteCount < 0) throw new IllegalArgumentException("byteCount < 0: " + byteCount);
234 readFrom(in, byteCount, false);
238 private void readFrom(InputStream in, long byteCount, boolean forever) throws IOException {
240 while (byteCount > 0 || forever) {
242 int maxToCopy = (int) Math.min(byteCount, Segment.SIZE - tail.limit);
250 byteCount -= bytesRead;
528 @Override public ByteString readByteString(long byteCount) throws EOFException {
529 return new ByteString(readByteArray(byteCount));
532 @Override public void readFully(Buffer sink, long byteCount) throws EOFException {
533 if (size < byteCount) {
537 sink.write(this, byteCount);
541 long byteCount = size;
542 if (byteCount > 0) {
543 sink.write(this, byteCount);
545 return byteCount;
556 @Override public String readUtf8(long byteCount) throws EOFException {
557 return readString(byteCount, Util.UTF_8);
568 @Override public String readString(long byteCount, Charset charset) throws EOFException {
569 checkOffsetAndCount(size, 0, byteCount);
571 if (byteCount > Integer.MAX_VALUE) {
572 throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + byteCount);
574 if (byteCount == 0) return "";
577 if (s.pos + byteCount > s.limit) {
579 return new String(readByteArray(byteCount), charset);
582 String result = new String(s.data, s.pos, (int) byteCount, charset);
583 s.pos += byteCount;
584 size -= byteCount;
635 int byteCount;
641 byteCount = 1; // 7 bits (ASCII).
647 byteCount = 2; // 11 bits (5 + 6).
653 byteCount = 3; // 16 bits (4 + 6 + 6).
659 byteCount = 4; // 21 bits (3 + 6 + 6 + 6).
668 if (size < byteCount) {
669 throw new EOFException("size < " + byteCount + ": " + size
676 for (int i = 1; i < byteCount; i++) {
688 skip(byteCount);
713 @Override public byte[] readByteArray(long byteCount) throws EOFException {
714 checkOffsetAndCount(size, 0, byteCount);
715 if (byteCount > Integer.MAX_VALUE) {
716 throw new IllegalArgumentException("byteCount > Integer.MAX_VALUE: " + byteCount);
719 byte[] result = new byte[(int) byteCount];
737 @Override public int read(byte[] sink, int offset, int byteCount) {
738 checkOffsetAndCount(sink.length, offset, byteCount);
742 int toCopy = Math.min(byteCount, s.limit - s.pos);
768 /** Discards {@code byteCount} bytes from the head of this buffer. */
769 @Override public void skip(long byteCount) throws EOFException {
770 while (byteCount > 0) {
773 int toSkip = (int) Math.min(byteCount, head.limit - head.pos);
775 byteCount -= toSkip;
934 @Override public Buffer write(byte[] source, int offset, int byteCount) {
936 checkOffsetAndCount(source.length, offset, byteCount);
938 int limit = offset + byteCount;
949 size += byteCount;
962 @Override public BufferedSink write(Source source, long byteCount) throws IOException {
963 while (byteCount > 0) {
964 long read = source.read(this, byteCount);
966 byteCount -= read;
1125 @Override public void write(Buffer source, long byteCount) {
1178 checkOffsetAndCount(source.size, 0, byteCount);
1180 while (byteCount > 0) {
1182 if (byteCount < (source.head.limit - source.head.pos)) {
1185 && (byteCount + tail.limit - (tail.shared ? 0 : tail.pos) <= Segment.SIZE)) {
1187 source.head.writeTo(tail, (int) byteCount);
1188 source.size -= byteCount;
1189 size += byteCount;
1194 source.head = source.head.split((int) byteCount);
1212 byteCount -= movedByteCount;
1216 @Override public long read(Buffer sink, long byteCount) {
1218 if (byteCount < 0) throw new IllegalArgumentException("byteCount < 0: " + byteCount);
1220 if (byteCount > size) byteCount = size;
1221 sink.write(this, byteCount);
1222 return byteCount;
1306 int byteCount = bytes.size();
1307 if (size - offset < byteCount) {
1310 for (int i = 0; i < byteCount; i++) {
1431 * Returns an immutable copy of the first {@code byteCount} bytes of this buffer as a byte string.
1433 public ByteString snapshot(int byteCount) {
1434 if (byteCount == 0) return ByteString.EMPTY;
1435 return new SegmentedByteString(this, byteCount);