Package java.nio

Examples of java.nio.ByteBuffer.compact()


      logger.debug("sent {} bytes to wire", bytesWritten);
      if (!toSend.hasRemaining()) {
        logger.debug("sent all data in toSend buffer");
        closeOrRegisterForRead(key)// should probably only be done if the HttpResponse is finished
      } else {
        toSend.compact()// make room for more data be "read" in
      }
    } catch (IOException e) {
      logger.error("Failed to send data to client: {}", e.getMessage());
      Closeables.closeQuietly(channel);
    }
View Full Code Here


        int count=channel.write(buffer);  System.out.println("COUNT="+count);
        // check if all bytes where written
        if (buffer.hasRemaining()) {
            // if not all bytes were written, move the unwritten bytes to the beginning and
            // set position just after the last unwritten byte
            buffer.compact();
        } else { buffer.clear()}
        return (long)count;
    }

View Full Code Here

              do {
                inputBuffer.flip();
               
                if(!inputBuffer.hasRemaining() || forceRead) {
                 
                  inputBuffer.compact();
                  int read = rawIn.read(bufferIn);
   
                  if(read==-1)
                    throw new EOFException("Unexpected EOF whilst waiting for SSL unwrap");
                
View Full Code Here

                  inputBuffer.flip();
                }
   
                 res = engine.unwrap(inputBuffer, outputBuffer);
   
                 inputBuffer.compact();

                 forceRead = res.getStatus()==SSLEngineResult.Status.BUFFER_UNDERFLOW;
                
              } while(forceRead);
             
View Full Code Here

               
             if (read > 0) {
                int size = outChannel.write(copyBuffer);
                written.addAndGet(size);
                if (copyBuffer.hasRemaining()) {
                   copyBuffer.compact();
                } else {
                   copyBuffer.clear();
                }
             }
          }
View Full Code Here

               
             if (read > 0) {
                int size = outChannel.write(copyBuffer);
                written.addAndGet(size);
                if (copyBuffer.hasRemaining()) {
                   copyBuffer.compact();
                } else {
                   copyBuffer.clear();
                }
             }
          }
View Full Code Here

               
             if (read > 0) {
                int size = outChannel.write(copyBuffer);
                written.addAndGet(size);
                if (copyBuffer.hasRemaining()) {
                   copyBuffer.compact();
                } else {
                   copyBuffer.clear();
                }
             }
          }
View Full Code Here

               
             if (read > 0) {
                int size = outChannel.write(copyBuffer);
                written.addAndGet(size);
                if (copyBuffer.hasRemaining()) {
                   copyBuffer.compact();
                } else {
                   copyBuffer.clear();
                }
             }
          }
View Full Code Here

      if (! Arrays.equals(magic, METABLOCKMAGIC)) {
        throw new IOException("Meta magic is bad in block " + block);
      }
      // Toss the header. May have to remove later due to performance.
      buf.compact();
      buf.limit(buf.limit() - METABLOCKMAGIC.length);
      buf.rewind();
      return buf;
    }
View Full Code Here

        buf.get(magic, 0, magic.length);
        if (!Arrays.equals(magic, DATABLOCKMAGIC)) {
          throw new IOException("Data magic is bad in block " + block);
        }
        // Toss the header. May have to remove later due to performance.
        buf.compact();
        buf.limit(buf.limit() - DATABLOCKMAGIC.length);
        buf.rewind();

        readTime += System.currentTimeMillis() - now;
        readOps++;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.