Examples of rewind()


Examples of java.nio.ByteBuffer.rewind()

    }
    else {
      // Verify file header
      ByteBuffer buf = ByteBuffer.allocate((int)HEADER_LENGTH);
      fileChannel.read(buf, 0L);
      buf.rewind();

      if (buf.remaining() < HEADER_LENGTH) {
        throw new IOException("File too short to be a compatible data file");
      }
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    long offset = fileChannel.size();

    ByteBuffer buf = ByteBuffer.allocate(data.length + 4);
    buf.putInt(data.length);
    buf.put(data);
    buf.rewind();

    fileChannel.write(buf, offset);

    return offset;
  }
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

            if ( magicBuf.hasRemaining() ) return null;
            magicBuf.flip();
            // copy the read four byte into a buffer - we will need them again maybe
            preReadData = new byte[4];
            magicBuf.get( preReadData );
            magicBuf.rewind();
            // read the first four bytes as int
            int magicNo = magicBuf.getInt();
            isHttp = (magicNo != EJConstants.EJOE_MAGIC_NUMBER);
        }
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

        }

        // validate the data
        if ( !httpHeaderParser.isValid() )
        {
            headerBuf.rewind();
            throw new ParseException( httpHeaderParser.getClass().getName() + ": Invalid HTTP header detected!!!\n"
                    + IOUtil.decodeToString( headerBuf ), 0 );
        }

        return httpHeaderParser;
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    int tagSize = computeTagLength(compatibleTag, fields);
   
    ByteBuffer buf = ByteBuffer.allocate( tagSize + padding );
    create(compatibleTag, buf, fields, tagSize, padding);
   
    buf.rewind();
    return buf;
    }
   
  protected List createFields(Tag tag) throws UnsupportedEncodingException {
      List fields = new LinkedList();
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

                    String strValue = null;
                    ByteBuffer buffer = (ByteBuffer) value;
                    int toGet = Math.min(16, buffer.limit());
                    byte[] dst = new byte[toGet];
                    buffer.get(dst);
                    buffer.rewind();
                    strValue = new String(dst, 0, dst.length);
                    if (dst.length < buffer.limit()) {
                        strValue += "... [" + (buffer.limit() - toGet) + " bytes more]";
                    }
                    value = strValue;
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

  }

  private ByteBuffer readData(final long iOffset,final  int iSize) throws IOException {
    ByteBuffer buffer = getBuffer(iSize);
    channel.read(buffer, iOffset);
    buffer.rewind();
    return buffer;
  }

  private void writeData(final ByteBuffer iBuffer, final long iOffset) throws IOException {
    iBuffer.rewind();
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

                ByteBuffer pendingValue = record.getPendingDataBuffer();
                pendingValue.clear();
                PrimitiveJavaTypesUtil.primitiveToByteBuffer(objectToPersist, next, pendingValue);
                pendingValue.flip();
                transactionFile.getChannel().write(pendingValue);
                pendingValue.rewind();
            }else {
                try {
                    Utils.writePrimitive(objectToPersist, next,transactionFile);
                } catch (Exception e) {
                    throw new JodbIOException(e);
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

      int length = (int) file.length();
      // int segment_size = 1024 * 4096;
      // ByteBuffer buf = ByteBuffer.allocate(segment_size);
      ByteBuffer buf = getByteBuffer(nio_segment_size);
      // byte bytes[] = new byte[segment_size];
      buf.rewind();

      int numRead = 0;
      int total = 0;
      while ((numRead >= 0) && (total < length))
      {
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

        }
        total += numRead;
        // System.out.println("numRead: " + numRead + " total: " +
        // total);

        buf.rewind();
      }

      // return buf.array();
      return result;
    } catch (Exception e)
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.