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;
}
}
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();
}
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();
}
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);
}
}
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);
}
}
Aggregations