Package java.io

Examples of java.io.BufferedInputStream.skip()


    in = new BufferedInputStream(new ByteArrayInputStream(bytes), 12);
    try {
      in.skip(6);
      in.mark(8);
      in.skip(7);
      in.reset();
      assertTrue("Wrong bytes 2", in.read() == 6 && in.read() == 7);
    } catch (IOException e) {
      fail("Exception during mark test 3");
    }
View Full Code Here


    }

    //regression for HARMONY-667
        BufferedInputStream buf = new BufferedInputStream(null, 5);
        try {
            buf.skip(10);
            fail("Should throw IOException");
        } catch (IOException e) {
            //expected
        }                        
  }
View Full Code Here

        long total = raf.getFilePointer();
        raf.close();
        // Seek in the stream
        InputStream in = new BufferedInputStream(new FileInputStream(path));
        while (total != 0) {
            long skipped = in.skip(total);
            if (skipped > 0) {
                total -= skipped;
            }
        }
        return in;
View Full Code Here

      byte[] buffer = new byte[64 * 1024]; // 64kb buffer

      // open the file and go the the current position
      stream = new BufferedInputStream(new FileInputStream(_file));
      stream.skip(getCurrentPosition());

      // read the next 64kb chunk
      int bytesRead = stream.read(buffer, 0, buffer.length);

      // convert it into a UTF-8 string and check the line endings
View Full Code Here

        BufferedInputStream in = null;
        BufferedOutputStream out = null;
        try {
            in = new BufferedInputStream(new DataInputStream(new FileInputStream(fromFile)));
            out = new BufferedOutputStream(new DataOutputStream(new FileOutputStream(toFile)));
            long skippedBytes = in.skip((long) startIndex);
            if (skippedBytes != startIndex) {
                out.close();
                out = null;
                // logger.finer( "Start index '" + startIndex + "' greater than file '" + skippedBytes + "'.");
                File f = new File(toFile);
View Full Code Here

            // -----------------------------------------------------
            // Append the second part of the original file
            // logger.finer("Appending the second part of the original file...");
            long skipLength = toByte - fromByte;
            // logger.finer("Skipping  '" + skipLength + "' bytes in file  '" + file + "'...");
            long skippedBytes = in.skip(skipLength);
            if (skippedBytes == -1) {
                // logger.finer("End of file reached while skipping. No second part of original file to append.");
            } else {
                // logger.finest( "Read/Write the second part of the original file: starting from byte number '" + fromByte + "', file is '" + file + "'...");
                buf = new byte[4096];
View Full Code Here

            // logger.finest("Creating InputStream from file '" + file + "'...");
            in = new BufferedInputStream(new FileInputStream(new File(file)));

            // Jump to the start point
            // logger.finest("Skip '" + fromByte + "' bytes in file...");
            long skippedBytes = in.skip(fromByte);
            if (skippedBytes == -1) {
                String msg =
                        "File size is less than starting point (from byte) '" + fromByte + "' ...";
                // logger.finest(msg);
                throw new Exception(msg);
View Full Code Here

        }
        if (isChunkedRequest == true) {
          // skip CRLF
          long skipLen = 0;
          do {
            long skipCnt = reader.skip(HTTP.CRLF.length() - skipLen);
            if (skipCnt < 0)
              break;
            skipLen += skipCnt;
          } while (skipLen < HTTP.CRLF.length());
          // read next chunk size
View Full Code Here

  private void assertMagic(long offset, byte[] magicBytes, File file) throws Exception {
    BufferedInputStream in = new BufferedInputStream(
        new FileInputStream(file));
    try {
      in.skip(offset);

      byte[] actual = new byte[magicBytes.length];
      in.read(actual);
      assertArrayEquals(magicBytes, actual);
    } finally {
View Full Code Here

        // ---------- Done Reading the TGA header ---------- //

        // Skip image ID
        if (idLength > 0) {
            if (idLength != bis.skip(idLength)) {
                throw new IOException("Unexpected number of bytes in file - too few.");
            }
        }

        ColorMapEntry[] cMapEntries = null;
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.