Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static boolean extractTo(Context context, final String name, final String dir, final String dstName, byte endec[]) { File file = new File(dir + "/" + dstName); InputStream is = null; OutputStream os = null; try { is = context.getAssets().open(name); os = new FileOutputStream(file); byte bs[] = new byte[4096]; int rc = 0; if (endec != null && endec.length > 0) { int idx = 0; while ((rc = is.read(bs)) >= 0) { if (rc > 0) { for (int i = 0; i < rc; i++) { bs[i] ^= endec[idx++]; if (idx >= endec.length) { idx = 0; } } os.write(bs, 0, rc); } } } else { while ((rc = is.read(bs)) >= 0) { if (rc > 0) { os.write(bs, 0, rc); } } } return true; } catch (Exception e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } if (os != null) { try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } }