List of usage examples for java.io OutputStream write
public void write(byte b[], int off, int len) throws IOException
len
bytes from the specified byte array starting at offset off
to this output stream. From source file:Main.java
public static void copy(InputStream input, OutputStream output) throws IOException { // 32kb buffer final byte[] BUFFER = new byte[32 * 1024]; int bytesRead; while ((bytesRead = input.read(BUFFER)) != -1) { output.write(BUFFER, 0, bytesRead); }//from ww w .j a v a2 s . co m }
From source file:FileHelper.java
/** * Copy the data from the input stream to the output stream. * * @param in data source/*from www .j a va 2s. co m*/ * @param out data destination * @throws IOException in an input or output error occurs * * @since ostermillerutils 1.00.00 */ private static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[BUFFER_SIZE]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:ZipHandler.java
private static void writeInOutputStream(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[1024]; int len = 0;// ww w . jav a2 s . com while ((len = is.read(buf)) > 0) { os.write(buf, 0, len); } }
From source file:com.liferay.mobile.android.http.file.FileTransferUtil.java
public static void transfer(AbstractExecutionAwareRequest request, InputStream is, OutputStream os, FileProgressCallback callback) throws IOException { int count;//from w ww .j a v a 2s . co m byte data[] = new byte[4096]; while (((count = is.read(data)) != -1) && !isCancelled(callback)) { os.write(data, 0, count); if (callback != null) { callback.increment(count); } } os.flush(); if (isCancelled(callback)) { request.abort(); } }
From source file:com.ksc.util.IOUtils.java
/** * Copies all bytes from the given input stream to the given output stream. * Caller is responsible for closing the streams. * /* w ww . java 2 s .c om*/ * @throws IOException * if there is any IO exception during read or write. */ public static long copy(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[BUFFER_SIZE]; long count = 0; int n = 0; while ((n = in.read(buf)) > -1) { out.write(buf, 0, n); count += n; } return count; }
From source file:Main.java
/** * Copies all bytes from the input stream to the output stream. * Does not close or flush either stream. * * @param from the input stream to read from * @param to the output stream to write to * @return the number of bytes copied// w ww . j a va2 s .c o m * @throws IOException if an I/O error occurs */ private static long copy(InputStream from, OutputStream to) throws IOException { byte[] buf = new byte[8192]; long total = 0; while (true) { int r = from.read(buf); if (r == -1) { break; } to.write(buf, 0, r); total += r; } return total; }
From source file:Main.java
private static void copyFiles(InputStream source, File dest) throws IOException { OutputStream output = null; int bytesRead = 0; byte[] buf = null; try {/*www. ja v a2 s .co m*/ output = new FileOutputStream(dest); buf = new byte[1024]; while ((bytesRead = source.read(buf)) > 0) { output.write(buf, 0, bytesRead); } } finally { source.close(); output.close(); bytesRead = 0; output = null; source = null; buf = null; } }
From source file:Main.java
private static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[4096]; try {//from www. j a v a 2 s . c om while (true) { int bytes = in.read(buffer); if (bytes == -1) break; out.write(buffer, 0, bytes); } out.flush(); } finally { try { in.close(); } finally { out.close(); } } }
From source file:Main.java
public static void CopyStream(InputStream is, OutputStream os) { final int buffer_size = 1024; try {/*from w w w . j av a2 s .c om*/ byte[] bytes = new byte[buffer_size]; for (;;) { int count = is.read(bytes, 0, buffer_size); if (count == -1) break; os.write(bytes, 0, count); } } catch (Exception ex) { } }
From source file:android.wulongdao.thirdparty.mime.HttpMultipart.java
private static void writeBytes(final ByteArrayBuffer b, final OutputStream out) throws IOException { out.write(b.buffer(), 0, b.length()); }