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 transfer(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024 * 1024]; int len;//from ww w . j ava2 s. c om while ((len = in.read(buf)) > 0) out.write(buf, 0, len); }
From source file:Main.java
private static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; int n;/*from www. ja v a 2s . c o m*/ while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
From source file:Main.java
/** * Copy the content of the input stream into the output stream, using a temporary * byte array buffer whose size is defined by {@link #IO_BUFFER_SIZE}. * * @param in The input stream to copy from. * @param out The output stream to copy to. * * @throws java.io.IOException If any error occurs during the copy. *///from w ww. j a v a 2 s . co m public static void copy(InputStream in, OutputStream out) throws IOException { byte[] b = new byte[IO_BUFFER_SIZE]; int read; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } }
From source file:Main.java
private static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024 * 16]; int read;// w w w . j av a 2 s . c o m while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024 * 32]; int read;//from w w w . j a v a2 s.co m while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:Main.java
public static void streamCopy(final InputStream bodyIs, final OutputStream out) throws IOException { byte[] buffer = new byte[2048]; int read;/*from w w w .j av a2 s . c o m*/ while ((read = bodyIs.read(buffer)) > 0) { out.write(buffer, 0, read); } bodyIs.close(); out.close(); }
From source file:Main.java
public static void copyInputStreamToFile(InputStream in, File file) { try {/*from ww w. jav a 2s. c o m*/ OutputStream out = new FileOutputStream(file); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.close(); in.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); }/* w w w . ja v a2s. co m*/ }
From source file:Main.java
public static void streamTransfer(final InputStream in, final OutputStream out) { final byte[] buffer = new byte[8192]; int read;/*from w w w. j a v a 2 s. c o m*/ try { while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } catch (final IOException exception) { exception.printStackTrace(); } }
From source file:Main.java
private static void copyFile(File source, File destination) throws IOException { InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(destination); byte[] buffer = new byte[1024]; int length;//from w w w. j a v a 2s . c o m while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } out.flush(); out.close(); in.close(); }