Package java.io

Examples of java.io.RandomAccessFile.readFully()


            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

            System.out.println("where the file name points to a node bundle.");
            return;
        }
        RandomAccessFile f = new RandomAccessFile(args[0], "r");
        byte[] bundle = new byte[(int) f.length()];
        f.readFully(bundle);
        f.close();
        System.out.println(dump(bundle));
    }

    public String dump(byte[] bundle) throws IOException {
View Full Code Here

  {
    this.filename = filename;

    final RandomAccessFile raf = new RandomAccessFile(filename, "r");
    final byte[] headerBuffer = new byte[12];
    raf.readFully(headerBuffer);
    if (ByteAccessUtilities.readULong(headerBuffer, 0) != MAGIC_NUMBER)
    {
      raf.close();
      throw new IOException();
    }
View Full Code Here

      throw new IOException();
    }
    numFonts = ByteAccessUtilities.readLong(headerBuffer, 8);

    final byte[] offsetBuffer = new byte[(int) (4 * numFonts)];
    raf.readFully(offsetBuffer);

    final int size = (int) numFonts;
    offsets = new long[size];
    fonts = new TrueTypeFont[size];
    for (int i = 0; i < size; i++)
View Full Code Here

                    break;
                } else {
                    file.seek(startPos);
                    if(byteArray == null)
                        byteArray = new byte[chunkSize];
                    file.readFully(byteArray);
                    if(parseLinesFromLast(byteArray, lineCount, lastNLines)) {
                        break; // we got the last *lineCount* lines
                    }

                    // remove the last element in lastNLines for it might be an
View Full Code Here

  public static ByteString readBytesFromFile(String filename) {
    File fullPath = new File(getTestDataDir(), filename);
    try {
      RandomAccessFile file = new RandomAccessFile(fullPath, "r");
      byte[] content = new byte[(int) file.length()];
      file.readFully(content);
      return ByteString.copyFrom(content);
    } catch (IOException e) {
      // Throw a RuntimeException here so that we can call this function from
      // static initializers.
      throw new IllegalArgumentException(
View Full Code Here

                break;
            }
            raf.seek(0);
            for( long i=0; i+data.length < size; i+=data.length) {
                raf.seek(i);
                raf.readFully(data);
                ioCount++;
                now = System.currentTimeMillis();
                if( (now-start)>sampleInterval ) {
                    break;
                }
View Full Code Here

  public static ByteString readBytesFromFile(String filename) {
    File fullPath = new File(getTestDataDir(), filename);
    try {
      RandomAccessFile file = new RandomAccessFile(fullPath, "r");
      byte[] content = new byte[(int) file.length()];
      file.readFully(content);
      return ByteString.copyFrom(content);
    } catch (IOException e) {
      // Throw a RuntimeException here so that we can call this function from
      // static initializers.
      throw new IllegalArgumentException(
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

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.