java RandomAccessFile 向文件中写入数据,覆盖原来的数据
publicstaticvoidmain(String[]args)throwsIOException{//TODOcodeapplicationlogichereFil...
public static void main(String[] args) throws IOException {
// TODO code application logic here
File f1 = new File("F:\\netbeans\\FileRandomAccess","a.txt");
f1.createNewFile();
RandomAccessFile rf = new RandomAccessFile(f1,"rw");
rf.seek(4);
String s="abcdefg";
rf.writeBytes(s);
}
不想文件被覆盖,想插入,怎么办??? 展开
// TODO code application logic here
File f1 = new File("F:\\netbeans\\FileRandomAccess","a.txt");
f1.createNewFile();
RandomAccessFile rf = new RandomAccessFile(f1,"rw");
rf.seek(4);
String s="abcdefg";
rf.writeBytes(s);
}
不想文件被覆盖,想插入,怎么办??? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询