use of java.io.FilterOutputStream in project iaf by ibissource.
the class AmazonS3FileSystemTestHelper method _createFile.
@Override
public OutputStream _createFile(final String foldername, final String filename) throws IOException {
TemporaryFolder folder = new TemporaryFolder();
folder.create();
String fileName = folder.getRoot().getAbsolutePath() + "tempFile";
final File file = new File(fileName);
final FileOutputStream fos = new FileOutputStream(file);
final BufferedOutputStream bos = new BufferedOutputStream(fos);
FilterOutputStream filterOutputStream = new FilterOutputStream(bos) {
@Override
public void close() throws IOException {
super.close();
bos.close();
FileInputStream fis = new FileInputStream(file);
ObjectMetadata metaData = new ObjectMetadata();
metaData.setContentLength(file.length());
String filePath = foldername == null ? filename : foldername + "/" + filename;
s3Client.putObject(bucketName, filePath, fis, metaData);
fis.close();
file.delete();
}
};
return filterOutputStream;
}
use of java.io.FilterOutputStream in project iaf by ibissource.
the class FtpFileSystemTestHelper method completePendingCommand.
private FilterOutputStream completePendingCommand(OutputStream os) {
FilterOutputStream fos = new FilterOutputStream(os) {
@Override
public void close() throws IOException {
super.close();
ftpSession.ftpClient.completePendingCommand();
}
};
return fos;
}
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 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 VoldemortAdminTool method writeBinary.
private static void writeBinary(File outputFile, Printable printable) throws IOException {
OutputStream outputStream = null;
if (outputFile == null) {
outputStream = new FilterOutputStream(System.out) {
@Override
public void close() throws IOException {
flush();
}
};
} else {
outputStream = new FileOutputStream(outputFile);
}
DataOutputStream dataOutputStream = new DataOutputStream(new BufferedOutputStream(outputStream));
try {
printable.printTo(dataOutputStream);
} finally {
dataOutputStream.close();
}
}
Aggregations