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