Package java.io

Examples of java.io.FileInputStream.skip()


        {
            fIn = new FileInputStream(pdfFile);

            final int trailByteCount = (fileLen < readTrailBytes) ? (int) fileLen : readTrailBytes;
            buf = new byte[trailByteCount];
            fIn.skip(skipBytes = fileLen - trailByteCount);

            int off = 0;
            int readBytes;
            while (off < trailByteCount)
            {
View Full Code Here


        //open the map-output file
        mapOutputIn = SecureIOUtils.openForRead(
            new File(mapOutputFileName.toUri().getPath()), runAsUserName);

        //seek to the correct offset for the reduce
        mapOutputIn.skip(info.startOffset);
        long rem = info.partLength;
        int len =
          mapOutputIn.read(buffer, 0, (int)Math.min(rem, MAX_BYTES_TO_READ));
        while (rem > 0 && len >= 0) {
          rem -= len;
View Full Code Here

        //open the map-output file
        mapOutputIn = SecureIOUtils.openForRead(
            new File(mapOutputFileName.toUri().getPath()), runAsUserName);

        //seek to the correct offset for the reduce
        mapOutputIn.skip(info.startOffset);
        long rem = info.partLength;
        int len =
          mapOutputIn.read(buffer, 0, (int)Math.min(rem, MAX_BYTES_TO_READ));
        while (rem > 0 && len >= 0) {
          rem -= len;
View Full Code Here

        {
            fIn = new FileInputStream(pdfFile);

            final int trailByteCount = (fileLen < readTrailBytes) ? (int) fileLen : readTrailBytes;
            buf = new byte[trailByteCount];
            fIn.skip(skipBytes = fileLen - trailByteCount);

            int off = 0;
            int readBytes;
            while (off < trailByteCount)
            {
View Full Code Here

      String folder = prj.getCanonicalPath();
      folder = folder.substring(0, folder.lastIndexOf(System.getProperty("file.separator")));

      //skips the header in .prj
      in.skip(PRJ_HEADER_BYTE_SIZE);

      //int c;
      int read;

      //reading project name.
View Full Code Here

    byte flags = (byte)(compressedBuf[3] & 0xff);
    if ((flags & 0x04) != 0) {   // FEXTRA
      numBytesRead = in.read(compressedBuf, 0, 2);
      assertEquals("XLEN bytes read", 2, numBytesRead);
      int xlen = ((compressedBuf[1] << 8) | compressedBuf[0]) & 0xffff;
      in.skip(xlen);
    }
    if ((flags & 0x08) != 0) {   // FNAME
      while ((numBytesRead = in.read()) != 0) {
        assertFalse("unexpected end-of-file while reading filename",
                    numBytesRead == -1);
View Full Code Here

            //new File(mapOutputFileName.toUri().getPath()), runAsUserName);

        ReadaheadRequest curReadahead = null;
       
        //seek to the correct offset for the reduce
        mapOutputIn.skip(info.startOffset);
        long rem = info.partLength;
        long offset = info.startOffset;
        while (rem > 0) {
          if (tracker.manageOsCacheInShuffle && tracker.readaheadPool != null) {
            curReadahead = tracker.readaheadPool.readaheadStream(filePath,
View Full Code Here

        ReusableBuffer result = client.chunk(testFileName, start, end).get();
        assertEquals(end - start, result.remaining());
       
        byte[] testData = new byte[end - start];
        FileInputStream sIn = new FileInputStream(testFileName);
        sIn.skip(start);
        sIn.read(testData, 0, end - start);
        sIn.close();
       
        assertEquals(new String(testData), new String(result.array()));
       
View Full Code Here

   *             if block cannot be read
   */
  public MapBlock read() throws IOException {
    FileInputStream fis = new FileInputStream(this.file);

    long skippedBytes = fis.skip(sequentialIndex);
    if (skippedBytes != sequentialIndex) {
      throw new IOException("Cannot jump to block position.");
    }
    // a block contains 196 bytes
    sequentialIndex = sequentialIndex + MAP_BLOCK_LENGTH;
View Full Code Here

      throw new IOException("Given coordinates are outside of map.");
    }
    int blockIndex = (x * MAP_HEIGHT) + y;

    FileInputStream fis = new FileInputStream(this.file);
    long skippedBytes = fis.skip(blockIndex * MAP_BLOCK_LENGTH);
    if (skippedBytes != (blockIndex * MAP_BLOCK_LENGTH)) {
      throw new IOException("Cannot read map block at given coordinates.");
    }

    try {
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.