class Demo
{
public static void main(String[] args)
{
//写
File f = new File("路径名");
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos =new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while((len = fis.read(buffer)) !=-1){
bos.write(buffer, 0 , len);
}
//读
File f = new File("路径名");
FileOutputStream fos = new FileOutputStream(file);
fos.write("haha:12345".getBytes());
}
}
最基本的JavaIO流操作代码
最新推荐文章于 2023-10-15 19:18:43 发布