Package java.io

Examples of java.io.FileInputStream.skip()


        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


    public void test_skipNegativeArgumentJ() throws IOException{
       
        FileInputStream fis = new java.io.FileInputStream(fileName);

        try {
            fis.skip(-5);
            fail("IOException must be thrown if number of bytes to skip <0");
        } catch (IOException e) {
            // Expected IOException
        } catch (Exception e) {
            fail("IOException expected, but found: " + e.getMessage());
View Full Code Here

   */
  public static Reader getReader(File _f, String encoding) throws IOException {
    int BOMType = getBOMType(_f);
    int skipBytes = getSkipBytes(BOMType);
    FileInputStream fIn = new FileInputStream(_f);
    fIn.skip(skipBytes);
    Reader reader = new InputStreamReader(fIn, encoding);
    return reader;
  }
}
View Full Code Here

        // Look up for ID3v1 tag
        if ((size == mediaLength) && (mediaLength != AudioSystem.NOT_SPECIFIED))
        {
            FileInputStream fis = (FileInputStream) inputStream;
            byte[] id3v1 = new byte[128];
            long bytesSkipped = fis.skip(inputStream.available() - id3v1.length);
            int read = fis.read(id3v1, 0, id3v1.length);
            if ((id3v1[0] == 'T') && (id3v1[1] == 'A') && (id3v1[2] == 'G'))
            {
                parseID3v1Frames(id3v1, aff_properties);
            }
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

        {
            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

                        inputStream = header.isBase64() ? new Base64InputStream(bis): bis;
                    }
                    try{
                        long nSkip;
                        long toSkip=header.getHeaderSize();
                        while((nSkip=fis.skip(toSkip))!=toSkip){
                            if(-1==nSkip) throw new RuntimeException("Unexcepted end of file in chunk file "+in.getCanonicalPath());
                            toSkip-=nSkip;
                        }
                        raf.seek(header.dataOffset);
                        int nRead;
View Full Code Here

            }

            final FileInputStream fis = new FileInputStream(file);

            if (pos > 0) {
                final long actualPos = fis.skip(pos);
            }

            final BufferedInputStream  bis = new BufferedInputStream(fis);
            final CountdownInputStream cis = new CountdownInputStream(bis);
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

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.