Here you can find the source of copyFile(final InputStream in, final OutputStream out, final int size)
Parameter | Description |
---|---|
in | Ingoing File |
out | Outgoing File |
size | Byte Buffer Size (in bytes) |
public static void copyFile(final InputStream in, final OutputStream out, final int size)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.io.InputStream; import java.io.OutputStream; public class Main { /**//from w ww . j a va 2 s . co m * Copy a file from one location to another * * @param in * Ingoing File * @param out * Outgoing File * @param size * Byte Buffer Size (in bytes) */ public static void copyFile(final InputStream in, final OutputStream out, final int size) { try { final byte[] buffer = new byte[size]; int length; while ((length = in.read(buffer)) > 0) out.write(buffer, 0, length); } catch (final Exception e) { e.printStackTrace(); } finally { try { in.close(); out.close(); } catch (final Exception e) { e.printStackTrace(); } } } }