Here you can find the source of copyTo(Context context, String fromPath, String toFile)
public static void copyTo(Context context, String fromPath, String toFile)
//package com.java2s; import android.content.*; import java.io.*; public class Main { public static void copyTo(Context context, String fromPath, String toFile) {/*w w w. ja v a2 s . c om*/ try { if (!new File(toFile).exists()) { new File(toFile).createNewFile(); } InputStream fromFileIs = context.getResources().getAssets() .open(fromPath); int length = fromFileIs.available(); byte[] buffer = new byte[length]; FileOutputStream fileOutputStream = new FileOutputStream(toFile); BufferedInputStream bufferedInputStream = new BufferedInputStream( fromFileIs); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream( fileOutputStream); int len = bufferedInputStream.read(buffer); while (len != -1) { bufferedOutputStream.write(buffer, 0, len); len = bufferedInputStream.read(buffer); } bufferedInputStream.close(); bufferedOutputStream.close(); fromFileIs.close(); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } } }