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 long copyLarge(InputStream input, OutputStream output) throws IOException { byte[] buffer = new byte[4096]; long count = 0L; int n = 0;/*from ww w.ja v a2 s. c o m*/ while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
From source file:com.janoz.usenet.support.LogUtil.java
private static void copyStream(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[BUFF_SIZE]; int len;/*from ww w.ja va 2 s . co m*/ while ((len = in.read(buffer)) >= 0) { out.write(buffer, 0, len); } in.close(); out.close(); }
From source file:Main.java
public static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[8192]; int read;/*from w w w . j a va 2 s . co m*/ while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } out.flush(); }
From source file:Main.java
/** * From http://stackoverflow.com/questions/9292954/how-to-make-a-copy-of-a-file-in-android */// ww w .j a v a2s.com public static void copy(File src, File dst) throws IOException { InputStream in = new FileInputStream(src); OutputStream out = new FileOutputStream(dst); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
From source file:Main.java
public static boolean copyFile(InputStream sourceFile, File destFile) throws IOException { OutputStream out = new FileOutputStream(destFile); byte[] buf = new byte[4096]; int len;/*from w w w . ja v a 2s. c o m*/ while ((len = sourceFile.read(buf)) > 0) { Thread.yield(); out.write(buf, 0, len); } out.close(); return true; }
From source file:Main.java
public static void transfer(InputStream in, OutputStream out, int maxBytes) throws IOException { byte[] buf = new byte[maxBytes]; int done = 0; int len;//from ww w . j a va 2 s. c om while (done < maxBytes && (len = in.read(buf)) > 0) { out.write(buf, 0, len); done += len; } }
From source file:de.xwic.appkit.core.remote.client.IoUtil.java
/** * @param input/* w ww. j av a 2 s . c om*/ * @param output * @param buffer * @return * @throws IOException */ private static void copy(final InputStream in, final OutputStream out) throws IOException { int n; final byte[] buffer = new byte[4096]; while (EOF != (n = in.read(buffer))) { out.write(buffer, 0, n); } }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) { final byte[] buf = new byte[1024]; int len;// w w w .j av a 2 s. com try { while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } catch (final IOException e) { throw new RuntimeException(e); } closeQuietly(in); closeQuietly(out); }
From source file:Main.java
public static long copy(@NonNull final InputStream input, @NonNull final OutputStream output) throws IOException { byte[] buffer = new byte[1024 * 4]; long count = 0; int n = 0;//from ww w . ja v a 2s. c o m while (-1 != (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}./* w ww . j ava 2s . c o m*/ * * @param in The input stream to copy from. * @param out The output stream to copy to. * @throws IOException If any error occurs during the copy. */ private 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); } }