package com.xuan.io;
import java.io.IOException;
import java.io.RandomAccessFile;
/*向指定文件追加内容*/
public class AppendContent {
public static void main(String[] args) {
RandomAccessFile raf=null;
try{
//以读、写方式打开一个RandomAccessFile对象
raf=new RandomAccessFile("out.txt","rw");
//将记录指针移动到out.txt文件的最后
raf.seek(raf.length());
raf.write("追加的内容!\r\n".getBytes());
}catch(IOException e){
e.printStackTrace();
}finally{
try{
if(raf!=null){
raf.close();
}
}catch(IOException e){
e.printStackTrace();
}
}
}
}
(44)使用IO流向指定文件追加内容
最新推荐文章于 2021-07-07 13:03:48 发布