Package java.io

Examples of java.io.RandomAccessFile.readFully()


        byte[] buf = new byte[5];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.skipBytes(5);
        raf.readFully(buf);
        assertEquals("Failed to skip bytes", "World", new String(buf, 0, 5));
        raf.close();
    }

    /**
 
View Full Code Here


        // java.io.RandomAccessFile.writeBytes(java.lang.String)
        byte[] buf = new byte[10];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.readFully(buf);
        assertEquals("Incorrect bytes read/written", "HelloWorld", new String(
                buf, 0, 10));
        raf.close();

    }
View Full Code Here

      //truncate blockFile
      blockRAF.setLength(newlen);
      //read last chunk
      blockRAF.seek(lastchunkoffset);
      blockRAF.readFully(b, 0, lastchunksize);
    } finally {
      blockRAF.close();
    }

    //compute checksum
View Full Code Here

   * @throws IOException if there is an I/O error while reading the file
   */
  private byte[] readFile(File file) throws IOException {
    RandomAccessFile raf = new RandomAccessFile(file, "r");
    byte[] buffer = new byte[(int) raf.length()];
    raf.readFully(buffer);
    raf.close();
    return buffer;
  }

  /**
 
View Full Code Here

            for (int i = 0; i < lastIndex; i++) {

                file.seek(recOffset[i]);
                len = recOffset[i+1] - recOffset[i];
                bytes = new byte[len];
                file.readFully(bytes);
    recArray[i] = new Record(bytes, recAttrs[i]);
      }
     
            // last record
            file.seek(recOffset[lastIndex]);
View Full Code Here

     
            // last record
            file.seek(recOffset[lastIndex]);
            len = (int) file.length() - recOffset[lastIndex];
            bytes = new byte[len];
            file.readFully(bytes);
            recArray[lastIndex] = new Record(bytes, recAttrs[lastIndex]);
    
        }

        file.close();
View Full Code Here

      {
        try
        {
          f = new RandomAccessFile(file, "r");
          content = new byte[(int) f.length()];
          f.readFully(content);

          if (file.getName().startsWith("Crest_Large_"))
          {
            _mapPledgeLarge.put(Integer.valueOf(file.getName()
                .substring(12, file.getName().length() - 4)),
View Full Code Here

    public byte[] getBytes() throws Exception{
        URL uri = getClass().getResource(fileName);
        RandomAccessFile raf = new RandomAccessFile(uri.getFile(),"r");
        byte[] bytes = new byte[(int)raf.length()];
        raf.readFully(bytes);
        return bytes;
    }
}
View Full Code Here

        // Test for method void java.io.RandomAccessFile.readFully(byte [])
        byte[] buf = new byte[10];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.readFully(buf);
        assertEquals("Incorrect bytes read/written", "HelloWorld", new String(
                buf, 0, 10));
        raf.close();
    }
View Full Code Here

        // int)
        byte[] buf = new byte[10];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.readFully(buf, 0, buf.length);
        assertEquals("Incorrect bytes read/written", "HelloWorld", new String(
                buf, 0, 10));
        try {
            raf.readFully(buf, 0, buf.length);
            fail("Reading past end of buffer did not throw EOFException");
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.