Package java.io

Examples of java.io.FileInputStream.skip()


            String orgName = config.getBootImage().getAbsolutePath();
            File orgFile = new File(orgName);

            // Compute the checksum over all 32-bit words starting at byte offset 64
            FileInputStream fis = new FileInputStream(orgFile);
            fis.skip(64);
            long checksum = 0;
            byte[] buffer = new byte[0x2000];
            while (fis.available() > 0) {
                int len = fis.read(buffer);
                for (int i = 0; i < len;) {
View Full Code Here


     final int toRead = (int) Math.min(iMaxSize, fileSize - offset);
     buffer = new byte[toRead];

     try {
       in.skip(offset);
       in.read(buffer);
       last = offset + toRead >= fileSize;

     } finally {
       try {
View Full Code Here

      }
      if(isRange()){
        System.out.println("Byte range: "+startByte+" - "+(getRangeSize()>0?endByte:""));
        long skipped=0;
        while(skipped<startByte){
          skipped+=is.skip(startByte);
        }
        ftc.writeAllData(is, endByte-startByte+1);
       
      }else{
        ftc.writeAllData(is);
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

    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

                }
            } else {
                buffer = new byte[(int) newPaddingSize];

                // skip the tag
                inStream.skip(mp3start);

                // write zeros for the tag
                outStream.write(buffer, 0, buffer.length);
            }
            buffer = new byte[1024];
View Full Code Here

                // Create a buffer and an input stream for the file
                final FileInputStream inputStream = new FileInputStream(this.file);
                byte buffer[] = new byte[DEFAULT_BUFFER_SIZE];

                // Put the file pointer at the right position
                final long nbBytesSkipped = inputStream.skip(this.index.getOffsetOfLine(lineNumber));
                JTailLogger.debug("Offset of line {} : {}", lineNumber, this.index.getOffsetOfLine(lineNumber));
                JTailLogger.debug("Skipped {} bytes", nbBytesSkipped);

                // Read the file
                int totalNbCharRead = 0;
View Full Code Here

    public GribRecord getRecord(int iRecord) throws BadGribException {
        long pos=arrRecordsPos[iRecord];
        try {
            FileInputStream in = new FileInputStream(gribFile);
            GribRecord gr;
            in.skip(pos);
            gr = new GribRecord(in);
            in.close();
           
            return gr;
        } catch (FileNotFoundException e) {
View Full Code Here

                            public int available() throws IOException {
                                return (int) dataLen;
                            }
                        };
                        fis.skip(startFrom);

                        res = new Response(HTTP_PARTIALCONTENT, mime, fis);
                        res.addHeader("Content-Length", "" + dataLen);
                        res.addHeader("Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen);
                        res.addHeader("ETag", etag);
View Full Code Here

     */
    protected BufferedReader getLogFileReader(long fromFilePosition) {
        FileInputStream file = null;
        try {
            file = new FileInputStream(getLogFileName());
            long bytesSkipped = file.skip(fromFilePosition);
            if (bytesSkipped != fromFilePosition) {
                if (LogFacade.LOGGING_LOGGER.isLoggable(Level.FINE)) {
                    LogFacade.LOGGING_LOGGER.log(Level.FINE, "Did not skip exact bytes while positioning reader in " + getLogFileName());
                }
            }
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.