0
点赞
收藏
分享

微信扫一扫

io流的字节的读取和写入

凛冬已至夏日未远 2022-02-10 阅读 115


写一个简单的写入和读取

读取

package contorller;

import java.io.FileOutputStream;
import java.io.IOException;

public class ZIj {
public static void main(String []args) throws IOException {
FileOutputStream f=new FileOutputStream("d:/w.txt",true);
f.write(1);
f.write(2);
f.flush();
}
}

结果

1

2

写入

package contorller;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class RZIJ {
public static void main(String[]args) throws IOException {
FileInputStream f=new FileInputStream("d:/w.txt");
int b=f.read();
int c=f.read();
System.out.println(b);
System.out.println(c);

}
}

这上面只是我的简单写法,利用字节数组是一样的意思




举报

相关推荐

0 条评论