Search in sources :

Example 46 with FilterOutputStream

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;
}
Also used : FileOutputStream(java.io.FileOutputStream) TemporaryFolder(org.junit.rules.TemporaryFolder) FilterOutputStream(java.io.FilterOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) FileInputStream(java.io.FileInputStream)

Example 47 with 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;
}
Also used : FilterOutputStream(java.io.FilterOutputStream)

Example 48 with FilterOutputStream

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();
    }
}
Also used : FileWriter(java.io.FileWriter) OutputStreamWriter(java.io.OutputStreamWriter) FilterOutputStream(java.io.FilterOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer) BufferedWriter(java.io.BufferedWriter)

Example 49 with FilterOutputStream

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();
    }
}
Also used : FileWriter(java.io.FileWriter) OutputStreamWriter(java.io.OutputStreamWriter) FilterOutputStream(java.io.FilterOutputStream) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) BufferedWriter(java.io.BufferedWriter)

Example 50 with FilterOutputStream

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();
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) DataOutputStream(java.io.DataOutputStream) FilterOutputStream(java.io.FilterOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) FilterOutputStream(java.io.FilterOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

FilterOutputStream (java.io.FilterOutputStream)59 IOException (java.io.IOException)35 ByteArrayOutputStream (java.io.ByteArrayOutputStream)19 OutputStream (java.io.OutputStream)19 FileOutputStream (java.io.FileOutputStream)15 ByteArrayInputStream (java.io.ByteArrayInputStream)13 File (java.io.File)12 Support_OutputStream (tests.support.Support_OutputStream)12 Test (org.junit.Test)9 FileInputStream (java.io.FileInputStream)8 InputStream (java.io.InputStream)8 BufferedOutputStream (java.io.BufferedOutputStream)7 FilterInputStream (java.io.FilterInputStream)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)6 ByteSink (com.google.common.io.ByteSink)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 File (com.hierynomus.smbj.share.File)3 DataOutputStream (java.io.DataOutputStream)3 OutputStreamWriter (java.io.OutputStreamWriter)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3