[java]代码库
import java.io.*;
public class FiletoJpg {
/**
*
* @param jpgPath
* 原始文件
* @param filePath
* 要追加的文件
* @return
*/
public static boolean toJpg(String jpgPath, String filePath) {
try {
RandomAccessFile randomFile = new RandomAccessFile(jpgPath, "rw");
FileInputStream fls = new FileInputStream(new File(filePath));
byte[] b = new byte[fls.available()];
fls.read(b);
long l = randomFile.length();
// 将指针移到末尾
randomFile.seek(l);
randomFile.write(b);
fls.close();
randomFile.close();
return true;
} catch (IOException e) {
System.out.println(e);
}
return false;
}
}