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
private static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[12024]; int read;//from ww w . jav a2 s . c o m while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:Main.java
private static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int read;// w w w.j av a 2 s .c om while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } }
From source file:Main.java
private static void copyFileUsingStream(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024]; int read;/* www . j a v a 2 s. c o m*/ while ((read = in.read(buf)) != -1) { out.write(buf, 0, read); } }
From source file:Main.java
static void copyFile(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;//w w w.j a va2 s. c o m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); }
From source file:com.ebay.nest.io.sede.lazy.LazyDate.java
/** * Writes a Date in SQL date format to the output stream. * @param out/*from w w w .j a v a 2 s .c o m*/ * The output stream * @param i * The Date to write * @throws IOException */ public static void writeUTF8(OutputStream out, DateWritable d) throws IOException { ByteBuffer b = Text.encode(d.toString()); out.write(b.array(), 0, b.limit()); }
From source file:Main.java
public static long copyLarge(InputStream input, OutputStream output, byte[] buffer) throws IOException { long count = 0; int n = 0;//from w w w .j av a 2 s. c o m while (EOF != (n = input.read(buffer))) { output.write(buffer, 0, n); count += n; } return count; }
From source file:Main.java
/** * @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. *//*from w w w.ja v a2 s. co m*/ private static void copyStream(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
public static void writeExtractedFileToDisk(InputStream in, OutputStream outs) throws IOException { byte[] buffer = new byte[1024]; int length;/* w ww. ja v a 2 s . c o m*/ while ((length = in.read(buffer)) > 0) { outs.write(buffer, 0, length); } outs.flush(); outs.close(); in.close(); }
From source file:StreamUtils.java
/** * Reads the content of an input stream and writes it into an output stream. * The copy is made in chunks of 512 bytes. * @param is the input/*from w w w .j a v a 2s. c o m*/ * @param os the output * @throws IOException thrown by the {@code read} and {@code write} methods of the streams */ public static void readWrite(InputStream is, OutputStream os) throws IOException { byte[] buf = new byte[512]; int nRead; while ((nRead = is.read(buf)) != -1) { os.write(buf, 0, nRead); } }
From source file:Main.java
public static void copy(InputStream in, OutputStream out) throws IOException { byte[] buf = new byte[1024]; int len;//from w w w .jav a 2 s .c o m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } out.flush(); in.close(); out.close(); }