整个过程以及结果为什么是这样啊(语言-java)
整个过程以及结果为什么是这样啊(语言-java)
RandomAccessFile 配置了访问模式 会将该文件重新写入进去
FileOutputStream 没有给要写入什么东西所以写入了空进去
public static void main(String[] ags) throws IOException {
File f = new File("E.java");
//rw 该访问模式为 :以读、写方式打开指定文件。如果该文件尚不存在,则尝试创建该文件。
RandomAccessFile in = new RandomAccessFile(f, "rw");
System.out.println(f.length());
//由于当前FileOutputStream 没有写入任何东西所以将E.java置空了
FileOutputStream out = new FileOutputStream(f);
out.write("zs".getBytes());
System.out.println(f.length());
}