Package java.nio

Examples of java.nio.ByteBuffer.clear()


    final int micros = fraction * 1000;

    SnoopPacketRecordImpl.initBuffer(data, included, original, record, drops,
        seconds, micros);

    data.clear();

    return data;
  }

  public static void initBuffer(final ByteBuffer b, final int included,
View Full Code Here


  public static ByteOrder checkFormat(ReadableByteChannel in)
      throws IOException {

    ByteBuffer b = ByteBuffer.allocate(8);
    in.read(b);
    b.clear();

    if (SnoopFile.headerReader.readType(b) != RecordType.BlockRecord) {
      return null;
    }
View Full Code Here

    r.put(b);

    /*
     * Now reset the buffer
     */
    r.clear();

    return r;
  }

  private ByteBuffer[] convertToBufferArray(final SnoopRecord[] elements)
View Full Code Here

      }
      else{
        bin.put(in,0,in.length-(i%3));
        bin.flip();
        System.out.println("write buffer"+m.write(bin));
        bin.clear();
      }
      for(int j=0;j<in.length;j++){
        in[j]++;
      }
    }
View Full Code Here

        byte[] peerID = new byte[4];
        int peerPort;
        ByteBuffer data = Misc.getByteBuffer(4);
        for (int i = 0; i < source_count; i++) {
          for (int j = 0; j < 4; j++) {
            data.clear();
            data.rewind();
            byte b = packet_data.get();
            data.put(b);
            peerID[j] = Convert.intToByte(data.getInt(0));
          }
View Full Code Here

      packet.insertData(fileHash.getHash());
     
      ByteBuffer num = Misc.getByteBuffer(4);
     
      for(FileChunkRequest request : partsData) {
        num.clear();
        num.rewind();
        num.putInt(Convert.longToInt(request.getChunkBegin()));
        packet.insertData(num.array());
      }
     
View Full Code Here

              .getShort());
          ByteBuffer message_bytes = Misc
              .getByteBuffer(message_length);
          packet_data.get(message_bytes.array());
          String message = new String(message_bytes.array());
          message_bytes.clear();
          message_bytes = null;
          _peer_manager.receivedMessage(peerIP, peerPort, message);
          break;
        }
View Full Code Here

        num.putInt(Convert.longToInt(request.getChunkBegin()));
        packet.insertData(num.array());
      }
     
      for(FileChunkRequest request : partsData) {
        num.clear();
        num.rewind();
        num.putInt(Convert.longToInt(request.getChunkEnd()));
        packet.insertData(num.array());
      }
     
View Full Code Here

        block.position(0);
       
        writeChannel.write(block);
       
      }
      block.clear();
      System.gc();
      if ((bytes - byteCount)==0) return ;
     
      ByteBuffer block2 = Misc.getByteBuffer(bytes - byteCount);
     
View Full Code Here

      ByteBuffer block2 = Misc.getByteBuffer(bytes - byteCount);
     
      block2.position(0);
     
      writeChannel.write(block2);
      block2.clear();
    } catch (IOException e) {
           
      e.printStackTrace();
     
    }
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.