All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tukaani.xz.CountingOutputStream Maven / Gradle / Ivy

Go to download

This artifact contains the same classes as ${modularized.groupId}%${modularized.artifactId}%${modularized.version} but also a module-info.class

There is a newer version: 1.21.0
Show newest version
/*
 * CountingOutputStream
 *
 * Author: Lasse Collin 
 *
 * This file has been put into the public domain.
 * You can do whatever you want with this file.
 */

package org.tukaani.xz;

import java.io.OutputStream;
import java.io.IOException;

/**
 * Counts the number of bytes written to an output stream.
 * 

* The finish method does nothing. * This is FinishableOutputStream instead * of OutputStream solely because it allows * using this as the output stream for a chain of raw filters. */ class CountingOutputStream extends FinishableOutputStream { private final OutputStream out; private long size = 0; public CountingOutputStream(OutputStream out) { this.out = out; } public void write(int b) throws IOException { out.write(b); if (size >= 0) ++size; } public void write(byte[] b, int off, int len) throws IOException { out.write(b, off, len); if (size >= 0) size += len; } public void flush() throws IOException { out.flush(); } public void close() throws IOException { out.close(); } public long getSize() { return size; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy