Search in sources :

Example 66 with BufferedOutputStream

use of java.io.BufferedOutputStream in project android-classyshark by google.

the class DexLoaderBuilder method prepareDex.

private static boolean prepareDex(byte[] bytes, File dexInternalStoragePath) {
    BufferedInputStream bis = null;
    OutputStream dexWriter = null;
    try {
        bis = new BufferedInputStream(new ByteArrayInputStream(bytes));
        dexWriter = new BufferedOutputStream(new FileOutputStream(dexInternalStoragePath));
        byte[] buf = new byte[BUF_SIZE];
        int len;
        while ((len = bis.read(buf, 0, BUF_SIZE)) > 0) {
            dexWriter.write(buf, 0, len);
        }
        dexWriter.close();
        bis.close();
        return true;
    } catch (IOException e) {
        if (dexWriter != null) {
            try {
                dexWriter.close();
            } catch (IOException ioe) {
                throw new RuntimeException(ioe);
            }
        }
        if (bis != null) {
            try {
                bis.close();
            } catch (IOException ioe) {
                throw new RuntimeException(ioe);
            }
        }
        return false;
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream)

Example 67 with BufferedOutputStream

use of java.io.BufferedOutputStream in project android-classyshark by google.

the class IOUtils method bytesToFile.

public static void bytesToFile(byte[] bytes, File result) throws IOException {
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(result));
    bos.write(bytes);
    bos.flush();
    bos.close();
}
Also used : FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Example 68 with BufferedOutputStream

use of java.io.BufferedOutputStream in project libstreaming by fyhertz.

the class RtspClient method tryConnection.

private void tryConnection() throws IOException {
    mCSeq = 0;
    mSocket = new Socket(mParameters.host, mParameters.port);
    mBufferedReader = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
    mOutputStream = new BufferedOutputStream(mSocket.getOutputStream());
    sendRequestAnnounce();
    sendRequestSetup();
    sendRequestRecord();
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) BufferedOutputStream(java.io.BufferedOutputStream) Socket(java.net.Socket) RtpSocket(net.majorkernelpanic.streaming.rtp.RtpSocket)

Example 69 with BufferedOutputStream

use of java.io.BufferedOutputStream in project facebook-android-sdk by facebook.

the class AppEventStore method saveEventsToDisk.

// Only call from singleThreadExecutor
private static void saveEventsToDisk(PersistedEvents eventsToPersist) {
    ObjectOutputStream oos = null;
    Context context = FacebookSdk.getApplicationContext();
    try {
        oos = new ObjectOutputStream(new BufferedOutputStream(context.openFileOutput(PERSISTED_EVENTS_FILENAME, 0)));
        oos.writeObject(eventsToPersist);
    } catch (Exception e) {
        Log.w(TAG, "Got unexpected exception while persisting events: ", e);
        try {
            context.getFileStreamPath(PERSISTED_EVENTS_FILENAME).delete();
        } catch (Exception innerException) {
        // ignore
        }
    } finally {
        Utility.closeQuietly(oos);
    }
}
Also used : Context(android.content.Context) ObjectOutputStream(java.io.ObjectOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 70 with BufferedOutputStream

use of java.io.BufferedOutputStream in project stetho by facebook.

the class LightHttpServer method serve.

public void serve(SocketLike socket) throws IOException {
    LeakyBufferedInputStream input = new LeakyBufferedInputStream(socket.getInput(), 1024);
    OutputStream output = socket.getOutput();
    HttpMessageReader reader = new HttpMessageReader(input);
    HttpMessageWriter writer = new HttpMessageWriter(new BufferedOutputStream(output));
    SocketLike anotherSocketLike = new SocketLike(socket, input);
    LightHttpRequest scratchRequest = new LightHttpRequest();
    LightHttpResponse scratchResponse = new LightHttpResponse();
    LightHttpRequest request;
    // expect the client to just close the connection.
    while ((request = readRequestMessage(scratchRequest, reader)) != null) {
        final LightHttpResponse response = scratchResponse;
        response.reset();
        // Note, if we're upgrading to websockets, this will block for the lifetime of the
        // websocket session...
        boolean keepGoing = dispatchToHandler(anotherSocketLike, request, response);
        if (!keepGoing) {
            // Orderly shutdown, ignore response and break the loop.
            break;
        }
        writeFullResponse(response, writer, output);
    }
}
Also used : SocketLike(com.facebook.stetho.server.SocketLike) OutputStream(java.io.OutputStream) BufferedOutputStream(java.io.BufferedOutputStream) LeakyBufferedInputStream(com.facebook.stetho.server.LeakyBufferedInputStream) BufferedOutputStream(java.io.BufferedOutputStream)

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