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 in, OutputStream out) throws IOException { byte[] b = new byte[IO_BUFFER_SIZE]; int read;//from w ww . jav a 2s .com while ((read = in.read(b)) != -1) { out.write(b, 0, read); } out.flush(); }
From source file:Main.java
public static void copyFileStream(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[BUFFSIZE]; int n = 0;/*from ww w . j a v a2s . c om*/ while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); } input.close(); output.close(); }
From source file:Main.java
/** * Copies inputStream to outputStream in a somewhat buffered way * @param in Input stream/* www . j a va 2 s .c o m*/ * @param out Output stream * @throws IOException if the operation fails */ public static void copyStream(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:Main.java
/** * <pre>//from w w w .j a v a 2 s. co m * Convenient method to copy file. * </pre> * @param in {@link InputStream} of source file * @param out {@link OutputStream} of destination file */ public static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } in.close(); out.flush(); out.close(); }
From source file:Main.java
private static void copyStream(InputStream input, OutputStream output) throws IOException { byte[] buff = new byte[4096]; int len;//w w w.j a v a 2 s . c o m while ((len = input.read(buff)) != -1) { output.write(buff, 0, len); } }
From source file:Main.java
public static void copyFile(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst); byte[] buf = new byte[1024]; int len;/* ww w . j a v a 2 s . c om*/ while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws Exception { byte[] bucket = new byte[8 * 1024]; int bytesRead = 0; while ((bytesRead = in.read(bucket)) != -1) { out.write(bucket, 0, bytesRead); }/* w ww . j a v a 2 s . c o m*/ }
From source file:Main.java
/** * Performs copy of one stream into another. * @param is - input stream/*from w w w .j a va 2 s . c o m*/ * @param os - output stream * @throws IOException */ public static void copyStream(InputStream is, OutputStream os) throws IOException { byte[] buffer = new byte[1024]; int count = 0; while ((count = is.read(buffer)) != -1) { os.write(buffer, 0, count); } os.flush(); }
From source file:Main.java
static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; int n;/* w w w . j a va2s . c o m*/ while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
From source file:Main.java
private static void copy(InputStream in, OutputStream out) throws IOException { byte[] b = new byte[1024]; int read;/* w ww.j a v a 2 s . c om*/ while ((read = in.read(b)) != -1) { out.write(b, 0, read); } }