Here you can find the source of copyFileAsStream(String srcFilePathName, String dstFilePathName)
public static void copyFileAsStream(String srcFilePathName, String dstFilePathName) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; public class Main { public static void copyFileAsStream(String srcFilePathName, String dstFilePathName) throws IOException { FileInputStream fis = new FileInputStream(srcFilePathName); FileOutputStream fos = new FileOutputStream(dstFilePathName); byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i);/*from ww w . j a va2 s . c o m*/ } fis.close(); fos.close(); } public static void close(InputStream stream) { try { stream.close(); } catch (Exception e) { } } public static void close(OutputStream stream) { try { stream.flush(); stream.close(); } catch (Exception e) { } } public static void close(Reader reader) { try { reader.close(); } catch (Exception e) { } } public static void close(Writer writer) { try { writer.flush(); writer.close(); } catch (Exception e) { } } }