use of java.io.FilterOutputStream in project voldemort by voldemort.
the class VoldemortAdminTool method writeAscii.
private static void writeAscii(File outputFile, Writable writable) throws IOException {
Writer writer = null;
if (outputFile == null) {
writer = new OutputStreamWriter(new FilterOutputStream(System.out) {
@Override
public void close() throws IOException {
flush();
}
});
} else {
writer = new FileWriter(outputFile);
}
BufferedWriter bufferedWriter = new BufferedWriter(writer);
try {
writable.writeTo(bufferedWriter);
} finally {
bufferedWriter.close();
}
}
use of java.io.FilterOutputStream in project voldemort by voldemort.
the class AdminCommandStream method writeAscii.
private static void writeAscii(File outputFile, Writable writable) throws IOException {
Writer writer = null;
if (outputFile == null) {
writer = new OutputStreamWriter(new FilterOutputStream(System.out) {
@Override
public void close() throws IOException {
flush();
}
});
} else {
writer = new FileWriter(outputFile);
}
BufferedWriter bufferedWriter = new BufferedWriter(writer);
try {
writable.writeTo(bufferedWriter);
} finally {
bufferedWriter.close();
}
}
use of java.io.FilterOutputStream in project nutz by nutzam.
the class Sender method getOutputStream.
protected OutputStream getOutputStream() throws IOException {
OutputStream out = conn.getOutputStream();
if (progressListener == null)
return out;
return new FilterOutputStream(out) {
int count;
public void write(byte[] b, int off, int len) throws IOException {
super.write(b, off, len);
count += len;
progressListener.invoke(count);
}
};
}
use of java.io.FilterOutputStream in project lucene-solr by apache.
the class SerializedDVStrategy method createIndexableFields.
@Override
public Field[] createIndexableFields(Shape shape) {
//50% headroom over last
int bufSize = Math.max(128, (int) (this.indexLastBufSize * 1.5));
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(bufSize);
//receiver of byteStream's bytes
final BytesRef bytesRef = new BytesRef();
try {
ctx.getBinaryCodec().writeShape(new DataOutputStream(byteStream), shape);
//this is a hack to avoid redundant byte array copying by byteStream.toByteArray()
byteStream.writeTo(new FilterOutputStream(null) {
/*not used*/
@Override
public void write(byte[] b, int off, int len) throws IOException {
bytesRef.bytes = b;
bytesRef.offset = off;
bytesRef.length = len;
}
});
} catch (IOException e) {
throw new RuntimeException(e);
}
//cache heuristic
this.indexLastBufSize = bytesRef.length;
return new Field[] { new BinaryDocValuesField(getFieldName(), bytesRef) };
}
use of java.io.FilterOutputStream in project bnd by bndtools.
the class CombinedResource method write.
@Override
public void write(final OutputStream out) throws IOException, Exception {
OutputStream unclosable = new FilterOutputStream(out) {
@Override
public void close() {
// Ignore
}
};
for (Resource r : resources) {
r.write(unclosable);
unclosable.flush();
}
}
Aggregations