Android examples for java.io:BufferedInputStream
copy file To Memory
import android.content.Context; import android.content.res.AssetManager; import android.os.Environment; import android.text.format.DateFormat; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.ArrayList; public class Main{ public static void copyToMemory(Context context, String srcFilePath, String dictFileName) throws IOException { File srcFile = new File(srcFilePath); if (!srcFile.exists() || srcFile.isDirectory()) { return; }//from ww w. jav a 2 s . c o m BufferedInputStream inBufferedInputStream = new BufferedInputStream( new FileInputStream(srcFile)); FileOutputStream fos = context.openFileOutput(dictFileName, 0); BufferedOutputStream bos = new BufferedOutputStream(fos); byte[] b = new byte[1024 * 4]; int len; while ((len = inBufferedInputStream.read(b)) != -1) { bos.write(b, 0, len); bos.flush(); } inBufferedInputStream.close(); bos.close(); } }