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


        info.size = _storage.getSize(qcow2Path);
        FileInputStream strm = null;
        byte[] b = new byte[8];
        try {
            strm = new FileInputStream(qcow2File);
            strm.skip(24);
            strm.read(b);
        } catch (Exception e) {
            s_logger.warn("Unable to read qcow2 file " + qcow2Path, e);
            return null;
        } finally {
View Full Code Here

     public Long getVirtualSize(File file) {
         FileInputStream strm = null;
         byte[] b = new byte[8];
         try {
             strm = new FileInputStream(file);
             strm.skip(24);
             strm.read(b);
         } catch (Exception e) {
             s_logger.warn("Unable to read qcow2 file " + file, e);
             return null;
         } finally {
View Full Code Here

        FileInputStream strm = null;
        byte[] currentSize = new byte[8];
        byte[] creatorApp = new byte[4];
        try {
            strm = new FileInputStream(vhdFile);
            strm.skip(info.size - vhd_footer_size + vhd_footer_creator_app_offset);
            strm.read(creatorApp);
            strm.skip(vhd_footer_current_size_offset - vhd_footer_creator_ver_offset);
            strm.read(currentSize);          
        } catch (Exception e) {
            s_logger.warn("Unable to read vhd file " + vhdPath, e);
View Full Code Here

        byte[] creatorApp = new byte[4];
        try {
            strm = new FileInputStream(vhdFile);
            strm.skip(info.size - vhd_footer_size + vhd_footer_creator_app_offset);
            strm.read(creatorApp);
            strm.skip(vhd_footer_current_size_offset - vhd_footer_creator_ver_offset);
            strm.read(currentSize);          
        } catch (Exception e) {
            s_logger.warn("Unable to read vhd file " + vhdPath, e);
            throw new InternalErrorException("Unable to read vhd file " + vhdPath + ": " + e);
        } finally {
View Full Code Here

        FileInputStream strm = null;
        byte[] currentSize = new byte[8];
        byte[] creatorApp = new byte[4];
        try {
            strm = new FileInputStream(file);
            strm.skip(file.length() - vhd_footer_size + vhd_footer_creator_app_offset);
            strm.read(creatorApp);
            strm.skip(vhd_footer_current_size_offset - vhd_footer_creator_ver_offset);
            strm.read(currentSize);
        } catch (Exception e) {
            s_logger.warn("Unable to read vhd file " + file.getAbsolutePath(), e);
View Full Code Here

        byte[] creatorApp = new byte[4];
        try {
            strm = new FileInputStream(file);
            strm.skip(file.length() - vhd_footer_size + vhd_footer_creator_app_offset);
            strm.read(creatorApp);
            strm.skip(vhd_footer_current_size_offset - vhd_footer_creator_ver_offset);
            strm.read(currentSize);
        } catch (Exception e) {
            s_logger.warn("Unable to read vhd file " + file.getAbsolutePath(), e);
            throw new CloudRuntimeException("Unable to read vhd file " + file.getAbsolutePath() + ": " + e);
        } finally {
View Full Code Here

  // Default to full reply then
  reply = createDefaultReply(request, HTTP.OK) ;
  try {
      FileInputStream fis = new FileInputStream(file);
      // and escape the headers
      fis.skip(foffset);
      reply.setStream(fis);
  } catch (IOException ex) {
      Reply error = request.makeReply(HTTP.SERVICE_UNAVAILABLE);
      error.setContent(ex.getMessage());
      return error;
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

    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
        }
       
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.