Package java.io

Examples of java.io.FileInputStream.skip()


          catch ( NumberFormatException nfe ) {}
        }
      }

      FileInputStream fis = new FileInputStream( f );
      fis.skip( startFrom );
      Response r = new Response( HTTP_OK, mime, fis );
      r.addHeader( "Content-length", "" + (f.length() - startFrom));
      r.addHeader( "Content-range", "" + startFrom + "-" +
            (f.length()-1) + "/" + f.length());
      return r;
View Full Code Here


/*     */   public static Pict fromFile(File paramFile)
/*     */     throws QTException, IOException
/*     */   {
/* 214 */     FileInputStream localFileInputStream = new FileInputStream(paramFile);
/* 215 */     byte[] arrayOfByte = new byte[localFileInputStream.available() - 512];
/* 216 */     localFileInputStream.skip(512L);
/* 217 */     localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
/* 218 */     localFileInputStream.close();
/* 219 */     Pict localPict = new Pict(arrayOfByte.length, false);
/* 220 */     localPict.copyFromArray(0, arrayOfByte, 0, arrayOfByte.length);
/* 221 */     return localPict;
View Full Code Here

                    catch ( NumberFormatException nfe ) {}
                }
            }

            FileInputStream fis = new FileInputStream( f );
            fis.skip( startFrom );
            Response r = new Response( HTTP_OK, mime, fis );
            r.addHeader( "Content-length", "" + (f.length() - startFrom));
            r.addHeader( "Content-range", "" + startFrom + "-" +
                        (f.length()-1) + "/" + f.length());
            return r;
View Full Code Here

        computePosition();
       
        if(sdImageFile != null) {
            try {
                FileInputStream fis = new FileInputStream(sdImageFile);
                fis.skip(this.position);
                int read = fis.read(readBuffer);
                if(read < SECTOR_SIZE) {
                    logger.log(Level.WARNING, "not enough data to fill read buffer from SD image file");
                }
                fis.close();
View Full Code Here

        FileInputStream file = null;
        try {
            file = new FileInputStream(getLogFileName());
            long bytesToSkip = fromFilePosition-1;
            if (bytesToSkip > 0) {
                long bytesSkipped = file.skip(bytesToSkip);
                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

     * @tests java.io.FileInputStream#skip(long)
     */
    public void test_skipNegativeArgumentJ() throws IOException {
        FileInputStream fis = new FileInputStream(fileName);
        try {
            fis.skip(-5);
            fail("IOException must be thrown if number of bytes to skip <0");
        } catch (IOException e) {
            // Expected IOException
        } finally {
            fis.close();
View Full Code Here

            final long dataLen = newLen;
            FileInputStream fis = new FileInputStream( f ) {
              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

     * @tests java.io.FileInputStream#skip(long)
     */
    public void test_skipNegativeArgumentJ() throws IOException {
        FileInputStream fis = new FileInputStream(fileName);
        try {
            fis.skip(-5);
            fail("IOException must be thrown if number of bytes to skip <0");
        } catch (IOException e) {
            // Expected IOException
        } finally {
            fis.close();
View Full Code Here

        fis.close();
       
        fis = new FileInputStream(fileName);
        assertEquals(0, fis.getChannel().position());
        bs = new byte[10];
        fis.skip(100);
        assertEquals(100, fis.getChannel().position());
        r = fis.read(bs);
        assertEquals(110, fis.getChannel().position());
        fis.close();
    }
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

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.