Package java.io

Examples of java.io.RandomAccessFile.readFully()


        final RandomAccessFile raf = new RandomAccessFile(imageFileName, "r");
        try {
            final long offset = address - loadAddress;
            raf.seek(offset);
            final byte[] data = new byte[length];
            raf.readFully(data);

            File tmpFile = File.createTempFile("jnode", "bin");
            FileOutputStream os = new FileOutputStream(tmpFile);
            os.write(data);
            os.close();
View Full Code Here


      raf.seek(0);

      try
      {
        raf.readFully(buf2);
      }
      catch (EOFException eofe)
      {
        harness.check(buf2[testlength - 1],
                      teststr.charAt(teststr.length() - 1),
View Full Code Here

      raf.seek(0);

      try
      {
        raf.readFully(buf2, 0, testlength + 2);
      }
      catch (EOFException eofe)
      {
        harness.check(buf2[testlength - 1],
                      teststr.charAt(teststr.length() - 1),
View Full Code Here

        try {
            RandomAccessFile ras = new RandomAccessFile(System.getProperty("java.io.tmpdir", File.separator + "tmp") + File.separator + "passivation" + pointer.fileid + ".ser", "r");
            byte [] bytes = new byte[(int) pointer.bytesize];
            ras.seek(pointer.filepointer);
            ras.readFully(bytes);
            ras.close();
            return Serializer.deserialize(bytes);
        } catch (Exception e) {
            throw new org.apache.openejb.SystemException(e);
        }
View Full Code Here

        try {
            RandomAccessFile ras = new RandomAccessFile(System.getProperty("java.io.tmpdir", File.separator + "tmp") + File.separator + "passivation" + pointer.fileid + ".ser", "r");
            byte [] bytes = new byte[(int) pointer.bytesize];
            ras.seek(pointer.filepointer);
            ras.readFully(bytes);
            ras.close();
            return Serializer.deserialize(bytes);
        } catch (Exception e) {
            throw new org.apache.openejb.SystemException(e);
        }
View Full Code Here

            // we can now determine the size of the entry to read - go from current position to the next pointer
            int entry_size = (int) next;
            entry = new byte[entry_size];

            // fully read in the entry
            raf.readFully(entry);

            if (fifo.m_compress) {
                entry = fifo.decompress(entry);
            }
View Full Code Here

            // we can now determine the size of the entry to read - go from current position to the next pointer
            int entry_size = (int) next;
            entry = new byte[entry_size];

            // fully read in the entry
            raf.readFully(entry);

            if (last_entry) {
                // this was the last entry - let's shrink the file down to its minimal size
                initializeEmptyFile();
            } else {
View Full Code Here

       
        // TODO: we could reuse the buffer in dataIn if it's big enough to avoid
        // allocating byte[] arrays on every readItem.
        byte[] data=new byte[item.getSize()];
        file.seek(item.getOffset()+DataManager.ITEM_HEAD_SIZE);
        file.readFully(data);
        dataIn.restart(data);
        return marshaller.readPayload(dataIn);
    }
}
View Full Code Here

  }
 
  private static byte[] readAllBytes(String filename) throws IOException {
    RandomAccessFile file = new RandomAccessFile(new File(filename), "r");
    byte[] content = new byte[(int) file.length()];
    file.readFully(content);
    return content;
  }

  /**
   * Interface used to capture a single action to benchmark.
View Full Code Here

                    int len = random.nextInt(1000);
                    len = (int) Math.min(len, ra.length() - ra.getFilePointer());
                    byte[] b1 = new byte[len];
                    byte[] b2 = new byte[len];
                    trace("readFully " + len);
                    ra.readFully(b1, 0, len);
                    FileUtils.readFully(f, ByteBuffer.wrap(b2, 0, len));
                    buff.append("readFully " + len + "\n");
                    assertTrue(Arrays.equals(b1, b2));
                    break;
                }
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.