Package java.util.zip

Examples of java.util.zip.CheckedInputStream


        try {
            if (file.canRead()) {
                 checksum.reset();
                 FileInputStream fis = new FileInputStream(file);
                 CheckedInputStream check = new CheckedInputStream(fis, checksum);
                 BufferedInputStream in = new BufferedInputStream(check);
                 while (in.read() != -1) {
                     // Read the file
                 }
                 rval = Long.toString(check.getChecksum().getValue());
                 in.close();
            }
        } catch (Exception e) {
            rval = null;
        }
View Full Code Here


        if (input == null)
        {
          throw new MissingParameterException("InputStream object missing.");
        }
        checksum = new CRC32();
        checkedIn = new CheckedInputStream(input, checksum);
        in = new DataInputStream(checkedIn);
        load();
      }
      catch (IOException ioe)
      {
View Full Code Here

  }
 
  public long recalculateSchemaChecksum() {
    if (getMondrianSchemaFilename() != null) {
      try {
        CheckedInputStream cis = new CheckedInputStream(new FileInputStream(getMondrianSchemaFilename()), new CRC32());
        byte[] buf = new byte[1024];
        while(cis.read(buf) >= 0) {
        }
        return cis.getChecksum().getValue();
      } catch (IOException e) {
          e.printStackTrace();
      }
    }
    return -1;
View Full Code Here

            contents = file.getContents();
        } catch (CoreException e) {
            throw new CausedIOException("Failed to calculate checksum.", e);
        }

        CheckedInputStream in = new CheckedInputStream(contents, new Adler32());
        try {
            IOUtils.copy(in, new NullOutputStream());
        } catch (IOException e) {
            throw new CausedIOException("Failed to calculate checksum.", e);
        } finally {
            IOUtils.closeQuietly(in);
        }
        return in.getChecksum().getValue();
    }
View Full Code Here

        if (file.isDirectory()) {
            throw new IllegalArgumentException("Checksums can't be computed on directories");
        }
        InputStream in = null;
        try {
            in = new CheckedInputStream(new FileInputStream(file), checksum);
            IOUtils.copy(in, new NullOutputStream());
        } finally {
            IOUtils.closeQuietly(in);
        }
        return checksum;
View Full Code Here

        checksum.reset();

        InputStream input = null;
        try
        {
            input = new CheckedInputStream( new FileInputStream( file ), checksum );
            IOUtil.toByteArray( input );
        }
        catch( final IOException ioe )
        {
            final String message = REZ.getString( "checksum-failure", file );
View Full Code Here

        List<String> checksumInfo = new ArrayList(3);
        CRC32 crc32 = new CRC32();
        int length = 0;
        BufferedInputStream fileinputstream = new BufferedInputStream(
                new FileInputStream(new File(file)));
        for( CheckedInputStream checkedinputstream = new CheckedInputStream(
        fileinputstream, crc32); checkedinputstream.read() != -1;)
                length++;
        long cksum = crc32.getValue();
        fileinputstream.close();
        fileinputstream = null;
        crc32 = null;
View Full Code Here

    public SynchronizationResponse writeZip(InputStream in, String resEntry)
            throws IOException, ClassNotFoundException {
               
        SynchronizationResponse response = null;
        ZipInputStream zin               = null;
        CheckedInputStream cis           = null;
        ZipEntry entry                   = null;
        ObjectInputStream oin            = null;

        try {
            cis   = new CheckedInputStream(in, new CRC32());           
            zin   = new ZipInputStream(cis);           
            entry = zin.getNextEntry();

            while (entry != null) {

                String eName = entry.getName();

                if (isIgnoredEntry(eName)) {

                    // do nothing, skip this entry

                } else if (ServletProcessor.RESPONSE_ENTRY_NAME.equals(eName)) {

                    oin = new ObjectInputStream(zin);
                    response = (SynchronizationResponse) oin.readObject();

                } else {

                    writeZipEntry(entry, zin);
                }
               
                // next entry
                zin.closeEntry();
                entry = zin.getNextEntry();
            }                                   
            zin.close();
            zin = null;
            return response;

        } finally {
            if (cis != null) {
                try { cis.close(); } catch (Exception ex) { }
            }
            if (zin != null) {
                try { zin.close(); } catch (Exception ex) { }
            }
            if (oin != null) {
View Full Code Here

*/
public final class ChecksumHelper
{
    public static long getChecksum(InputStream is)
    {
        CheckedInputStream cis = null;       
        long checksum = 0;
        try
        {
            cis = new CheckedInputStream(is, new Adler32());
            byte[] tempBuf = new byte[128];
            while (cis.read(tempBuf) >= 0)
            {
            }
            checksum = cis.getChecksum().getValue();
        }
        catch (IOException e)
        {
            checksum = 0;
        }
        finally
        {
            if (cis != null)
            {
                try
                {
                    cis.close();
                }
                catch (IOException ioe)
                {                   
                }
            }
View Full Code Here

        if (file.isDirectory()) {
            throw new IllegalArgumentException("Checksums can't be computed on directories");
        }
        InputStream in = null;
        try {
            in = new CheckedInputStream(new FileInputStream(file), checksum);
            IOUtils.copy(in, new NullOutputStream());
        } finally {
            IOUtils.closeQuietly(in);
        }
        return checksum;
View Full Code Here

TOP

Related Classes of java.util.zip.CheckedInputStream

Copyright © 2018 www.massapicom. 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.