Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; import java.io.IOException; import java.io.RandomAccessFile; public class Main { public static boolean saveApk(File apk, String savePath) { FileInputStream in = null; RandomAccessFile accessFile = null; try { in = new FileInputStream(apk); byte[] buf = new byte[1024 * 4]; int len; File file = new File(savePath); accessFile = new RandomAccessFile(file, "rw"); FileDescriptor fd = accessFile.getFD(); while ((len = in.read(buf)) != -1) { accessFile.write(buf, 0, len); } fd.sync(); accessFile.close(); in.close(); return true; } catch (Exception e) { e.printStackTrace(); try { if (in != null) { in.close(); } if (accessFile != null) { accessFile.close(); } } catch (IOException e1) { e1.printStackTrace(); } return false; } } }