Java tutorial
//package com.java2s; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; public class Main { public static boolean appendFile(String filename, byte[] data, int datapos, int datalength) { try { createFile(filename); RandomAccessFile rf = new RandomAccessFile(filename, "rw"); rf.seek(rf.length()); rf.write(data, datapos, datalength); if (rf != null) { rf.close(); } } catch (Exception e) { e.printStackTrace(); } return true; } public static boolean createFile(String filePath) { try { File file = new File(filePath); if (!file.exists()) { if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } return file.createNewFile(); } } catch (IOException e) { e.printStackTrace(); } return true; } }