Package java.io

Examples of java.io.RandomAccessFile.skipBytes()


        // Test for method int java.io.RandomAccessFile.skipBytes(int)
        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, "UTF-8"));
        raf.close();
    }
View Full Code Here


        // Test for method int java.io.RandomAccessFile.skipBytes(int)
        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

        xml_os.close();
      }
    }
    RandomAccessFile raf = new RandomAccessFile(filename, "rw");
    try {
      raf.skipBytes(7);
      // int return_val =
      updateElement(raf, handler.countList, 0);
      // Debug.p("Return val: " + return_val);
    } finally {
      raf.close();
View Full Code Here

      // Make sure skipBytes goes all the way to the end of the file and no further
      int skipped = 0;

      for (int i = 0; i < testbytes.length + 1; i++)
      { // last skip should return 0 bytes
        int offset = raf.skipBytes(1);
        harness.debug("skipped " + offset + " bytes");
        skipped += offset;
      }

      harness.check(skipped, testlength, "skipBytes() did not skip past EOF");
View Full Code Here

    int skipped = 0;
    while (numDirectories-- > 0)
    {
      in.seek(nextIfdOffset);
      short numTags = readShort();
      in.skipBytes(numTags * 12);
      nextIfdOffset = readInt();
      if (nextIfdOffset == 0)
      {
        throw new InvalidFileStructureException("Could only skip " +
          skipped + " image file directories, no more images in file.");
View Full Code Here

        xml_os.close();
      }
    }
    RandomAccessFile raf = new RandomAccessFile(filename, "rw");
    try {
      raf.skipBytes(7);
      // int return_val =
      updateElement(raf, handler.countList, 0);
      // Debug.p("Return val: " + return_val);
    } finally {
      raf.close();
View Full Code Here

        // Test for method int java.io.RandomAccessFile.skipBytes(int)
        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

        // Test for method int java.io.RandomAccessFile.skipBytes(int)
        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

                RandomAccessFile a = new RandomAccessFile(f, "r");
                try {
                    getLengthAndPositionAtCentralDirectory(a);
                    // skip first two entries
                    a.skipBytes(2 * 47 /* CD entry of file with
                                          file name length 1 and no
                                          extra data */
                                + 2 * (mode == Zip64Mode.Always ? 4 : 0)
                                /* empty ZIP64 extra fields if mode is Always */
                                );
View Full Code Here

                            0, 8,
                            // method
                            0, 0
                        }, header);
                    // ignore timestamp, CRC, compressed size
                    a.skipBytes(12);
                    byte[] rest = new byte[23];
                    a.readFully(rest);
                    assertArrayEquals(new byte[] {
                            // Original Size
                            1, 0, 0, 0,
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.