java写的简单的文件合并,java文件合并,可是实现文件追加 吧文件
分享于 点击 13196 次 点评:211
java写的简单的文件合并,java文件合并,可是实现文件追加 吧文件
可是实现文件追加 吧文件B 追加到A 后当用到文件B改后缀名即可,文件B建议RAR格式否则例如word会出错
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; }}//该片段来自于http://byrx.net
用户点评