Here you can find the source of writeFileToDisk(File file, String targetPath)
public static void writeFileToDisk(File file, String targetPath)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static void writeFileToDisk(File file, String targetPath) { FileInputStream fis = null; FileOutputStream fos = null; try {//w ww. j a v a2 s .co m fis = new FileInputStream(file); fos = new FileOutputStream(targetPath); byte[] b = new byte[1]; while (fis.read(b) != -1) { fos.write(b); } fos.flush(); } catch (Exception e) { e.printStackTrace(); } finally { try { if (fis != null) { fis.close(); fis = null; } if (fos != null) { fos.close(); fos = null; } } catch (Exception e2) { e2.printStackTrace(); } } } }