Search in sources :

Example 51 with BufferedOutputStream

use of java.io.BufferedOutputStream in project LiveSDK-for-Android by liveservices.

the class LiveConnectClient method toByteArray.

/**
     * Converts an InputStream to a {@code byte[]}.
     *
     * @param is to convert to a {@code byte[]}.
     * @return a new {@code byte[]} from the InputStream.
     * @throws IOException if there was an error reading or closing the InputStream.
     */
private static byte[] toByteArray(InputStream is) throws IOException {
    ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    OutputStream out = new BufferedOutputStream(byteOut);
    is = new BufferedInputStream(is);
    byte[] buffer = new byte[BUFFER_SIZE];
    try {
        int bytesRead;
        while ((bytesRead = is.read(buffer)) != -1) {
            out.write(buffer, 0, bytesRead);
        }
    } finally {
        // we want to perform silent close operations
        closeSilently(is);
        closeSilently(out);
    }
    return byteOut.toByteArray();
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 52 with BufferedOutputStream

use of java.io.BufferedOutputStream in project camel by apache.

the class UnsharableCodecsConflicts2Test method sendBuffer.

public static void sendBuffer(byte[] buf, Socket server) throws Exception {
    OutputStream netOut = server.getOutputStream();
    OutputStream dataOut = new BufferedOutputStream(netOut);
    try {
        dataOut.write(buf, 0, buf.length);
        dataOut.flush();
    } catch (Exception e) {
        server.close();
        throw e;
    }
}
Also used : OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException)

Example 53 with BufferedOutputStream

use of java.io.BufferedOutputStream in project flink by apache.

the class CsvOutputFormat method open.

// --------------------------------------------------------------------------------------------
@Override
public void open(int taskNumber, int numTasks) throws IOException {
    super.open(taskNumber, numTasks);
    this.wrt = this.charsetName == null ? new OutputStreamWriter(new BufferedOutputStream(this.stream, 4096)) : new OutputStreamWriter(new BufferedOutputStream(this.stream, 4096), this.charsetName);
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) BufferedOutputStream(java.io.BufferedOutputStream)

Example 54 with BufferedOutputStream

use of java.io.BufferedOutputStream in project libgdx by libgdx.

the class HeadlessPreferences method flush.

@Override
public void flush() {
    OutputStream out = null;
    try {
        out = new BufferedOutputStream(file.write(false));
        properties.storeToXML(out, null);
    } catch (Exception ex) {
        throw new GdxRuntimeException("Error writing preferences: " + file, ex);
    } finally {
        StreamUtils.closeQuietly(out);
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Example 55 with BufferedOutputStream

use of java.io.BufferedOutputStream in project libgdx by libgdx.

the class JglfwPreferences method flush.

public void flush() {
    OutputStream out = null;
    try {
        out = new BufferedOutputStream(file.write(false));
        properties.store(out, null);
    } catch (Exception ex) {
        throw new GdxRuntimeException("Error writing preferences: " + file, ex);
    } finally {
        StreamUtils.closeQuietly(out);
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException)

Aggregations

BufferedOutputStream (java.io.BufferedOutputStream)1219 FileOutputStream (java.io.FileOutputStream)861 IOException (java.io.IOException)617 File (java.io.File)519 OutputStream (java.io.OutputStream)350 BufferedInputStream (java.io.BufferedInputStream)238 InputStream (java.io.InputStream)166 DataOutputStream (java.io.DataOutputStream)158 FileInputStream (java.io.FileInputStream)145 ZipOutputStream (java.util.zip.ZipOutputStream)121 FileNotFoundException (java.io.FileNotFoundException)113 ZipEntry (java.util.zip.ZipEntry)108 ByteArrayOutputStream (java.io.ByteArrayOutputStream)101 ZipFile (java.util.zip.ZipFile)62 URL (java.net.URL)57 XmlSerializer (org.xmlpull.v1.XmlSerializer)57 FastXmlSerializer (com.android.internal.util.FastXmlSerializer)56 ObjectOutputStream (java.io.ObjectOutputStream)54 GZIPOutputStream (java.util.zip.GZIPOutputStream)51 PrintStream (java.io.PrintStream)46