me.lightspeed7.mongofs.CountingOutputStream Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mongoFS Show documentation
Show all versions of mongoFS Show documentation
An extension to the MongoDB Java Driver library that goes beyond what the GridFS feature supports.
Compressed file storage, zip files, temporary files
package me.lightspeed7.mongofs;
import java.io.IOException;
import java.io.OutputStream;
public class CountingOutputStream extends OutputStream {
private long count = 0;
private MongoFileConstants key;
private MongoFile inputFile;
private OutputStream out;
public CountingOutputStream(final MongoFileConstants key, final MongoFile inputFile, final OutputStream out) {
this.key = key;
this.inputFile = inputFile;
this.out = out;
}
@Override
public void write(final int b) throws IOException {
out.write(b);
++count;
}
@Override
public void write(final byte[] b, final int off, final int len) throws IOException {
out.write(b, off, len);
count += len;
}
@Override
public void close() throws IOException {
out.close();
inputFile.put(key.toString(), count);
inputFile.save();
}
public long getCount() {
return count;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy