コード例 #1
0
 /**
  * Fill in our byte buffer if we're out of space by reading the next protocol buffer object.
  *
  * @throws IOException If {@link
  *     com.google.protobuf.MessageLite#writeDelimitedTo(java.io.OutputStream)} fails
  */
 private void fillBytes() throws IOException {
   if (currentBytes.available() > 0) {
     return;
   }
   currentBytes.reset();
   while (protoBufferIterator.hasNext() && currentBytes.size() <= 1000) {
     protoBufferIterator.next().writeDelimitedTo(currentBytes);
   }
 }
コード例 #2
0
 @Override
 public int read(byte[] b, int off, int len) throws IOException {
   int total_read = 0;
   while (len > 0) {
     fillBytes();
     int result = currentBytes.read(b, off, len);
     if (result == -1) {
       return total_read == 0 ? -1 : total_read;
     }
     len -= result;
     total_read += result;
     off += result;
   }
   return total_read;
 }
コード例 #3
0
 @Override
 public void close() throws IOException {
   super.close();
   currentBytes.close();
 }
コード例 #4
0
 @Override
 public int available() {
   return currentBytes.available();
 }
コード例 #5
0
 @Override
 public int read() throws IOException {
   fillBytes();
   return currentBytes.read();
 }