![JAR search and dependency download from the Maven repository](/logo.png)
bboss.org.jgroups.util.ExposedDataOutputStream Maven / Gradle / Ivy
The newest version!
package bboss.org.jgroups.util;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
/**
* @author Bela Ban
* @version $Id: ExposedDataOutputStream.java,v 1.3 2008/10/28 08:50:15 belaban Exp $
*/
public class ExposedDataOutputStream extends DataOutputStream {
/**
* Creates a new data output stream to write data to the specified
* underlying output stream. The counter written
is
* set to zero.
* @param out the underlying output stream, to be saved for later
* use.
* @see java.io.FilterOutputStream#out
*/
public ExposedDataOutputStream(OutputStream out) {
super(out);
}
public void reset() {
written=0;
}
public OutputStream getOutputStream() {
return out;
}
public void write(int b) throws IOException {
out.write(b);
incCount(1);
}
/**
* Writes len
bytes from the specified byte array
* starting at offset off
to the underlying output stream.
* If no exception is thrown, the counter written
is
* incremented by len
.
* @param b the data.
* @param off the start offset in the data.
* @param len the number of bytes to write.
* @throws IOException if an I/O error occurs.
* @see java.io.FilterOutputStream#out
*/
public void write(byte b[], int off, int len)
throws IOException {
out.write(b, off, len);
incCount(len);
}
private void incCount(int value) {
int temp=written + value;
if(temp < 0) {
temp=Integer.MAX_VALUE;
}
written=temp;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy