Package java.util.zip

Examples of java.util.zip.CheckedInputStream


    public static long doChecksum(String fileName) {
       long checksum = 0L;
        try {

            CheckedInputStream cis = null;
            long fileSize = 0;
            try {
                // Computer CRC32 checksum
                cis = new CheckedInputStream(
                        new FileInputStream(fileName), new CRC32());

                fileSize = new File(fileName).length();
              
            } catch (FileNotFoundException e) {
                System.err.println("File not found.");
                System.exit(1);
            }

            byte[] buf = new byte[128];
            while(cis.read(buf) >= 0) {
            }

            checksum = cis.getChecksum().getValue();

        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
View Full Code Here


public class ChecksummingPerfomance {

    public static void main(final String[] args) throws Exception {

        final CRC32 inputChecksum = new CRC32();
        final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test.data"), inputChecksum);
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));

        for (int i = 0; i < 30; i++) {
            long time = System.currentTimeMillis();
            StringBuffer buf = null;
View Full Code Here

        // System.out.println(inputChecksum.getValue());
    }

    private static StringBuffer readChecksummedFile(final int i) throws Exception {
        final CRC32 inputChecksum = new CRC32();
        final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test" + i % 3 + ".data"), inputChecksum);
        final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));

        final StringBuffer buf = new StringBuffer();
        String line;
        while ((line = reader.readLine()) != null) {
View Full Code Here

    private void syncConnection(final Socket connection, final int readTimeout) {
        try {
            final CRC32 crc32 = new CRC32();
            final DataOutput output = new DataOutputStream(connection.getOutputStream());
            final DataInput input = new DataInputStream(new CheckedInputStream(connection.getInputStream(), crc32));

            if (input.readByte() != INIT) {
                return;
            }
View Full Code Here

     *
     * @param in The uncompressed {@link InputStream}.
     */
    public GZIPCompressorInputStream(InputStream in)
    {
        super(new CheckedInputStream(in, new CRC32()), new Deflater(Deflater.DEFAULT_COMPRESSION, true));
        buffer = new Buffer();
    }
View Full Code Here

   */
  private boolean readHeader() throws IOException {

    if (!_eosReached) {

      CheckedInputStream in = new CheckedInputStream(this.in, _crc);

      _crc.reset();

      try {
        // Check header magic
View Full Code Here

  /*
   * Reads GZIP member header.
   */
  private void readHeader() throws IOException {

    CheckedInputStream in = new CheckedInputStream(this.in, _crc);

    _crc.reset();

    // Check header magic
    if (readUShort(in) != GZIP_MAGIC) {
View Full Code Here

                return; // this is a not a zip file and thus, not a big cod
            }
        }

        FileInputStream fis = new FileInputStream(codFile);
        CheckedInputStream checksum = new CheckedInputStream(fis, new Adler32());
        ZipInputStream zis = new ZipInputStream(new BufferedInputStream(
                checksum));

        ZipEntry entry;
        BufferedOutputStream dest = null;
View Full Code Here

    public void validate() throws ValidationException, PackageException {
        File f = new File(_archiveFile);
        try {
            FileInputStream fis = new FileInputStream(f);
            CheckedInputStream checksum = new CheckedInputStream(fis, new Adler32());
            ZipInputStream zis = new ZipInputStream(new BufferedInputStream(
                    checksum));
               
            // parse each zip file
            ZipEntry entry;
View Full Code Here

public class ChecksummingPerfomance {

    public static void main(String[] args) throws Exception {

        CRC32 inputChecksum = new CRC32();
        CheckedInputStream in = new CheckedInputStream(new FileInputStream("test.data"), inputChecksum);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));

        for (int i = 0; i < 30; i++) {
            long time = System.currentTimeMillis();
            StringBuffer buf = null;
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.