/**
* RandomAccessFile实现数据的插入
*/
@Test
public void test4() throws Exception {
RandomAccessFile raf1=new RandomAccessFile(new File("hello1.txt"),"rw");
raf1.seek(3);
StringBuilder stringBuilder=new StringBuilder((int) new File("hello1.txt").length());
byte[] bytes = new byte[20];
int len;
while ((len=raf1.read(bytes))!=-1){
stringBuilder.append(new String(bytes),0,len);
}
raf1.seek(3);
raf1.write("dddd".getBytes(StandardCharsets.UTF_8));
raf1.write(stringBuilder.toString().getBytes(StandardCharsets.UTF_8));
}