public class OutputDemo {
public static void main(String[] args) throws IOException {
//1.创建字节输出流的对象
FileOutputStream fos=new FileOutputStream("D:\\wangzhuo.txt");
//2.写数据
fos.write(97);
//3。释放资源
fos.close();
}
}
字节流一次写多个数据
public class OutputDemo1 {
public static void main(String[] args) throws IOException {
//1.创建字节输出流的对象
FileOutputStream fos=new FileOutputStream("D:\\wangzhuo.txt");
//2.写数据
/* byte[] bytes={97,98,99,100};
fos.write(bytes);*/
byte[] bytes1={97,98,99,100,101,102,103};
fos.write(bytes1,1,6);
//3。释放资源
fos.close();
}
}
字节流2个问题:换行 续写
try catch finally
try catch finally 标准格式代码
public class InputDemo {
public static void main(String[] args) throws IOException {
//1.创建字节输出流的对象
FileInputStream fis=new FileInputStream("D:\\wangzhuo.txt");
//2.读数据
int read = fis.read();
System.out.println(read);
//3。释放资源
fis.close();
}
}
字节流读数据 一次读取多个数据
======= 1数据源 2目的地概念======
定义数组拷贝文件 ↓
缓冲流 一次读写一个字节
缓冲流 一次读写一个数组
编码
解码
字符流读取中文的过程
写数据的注意事项:
1 一次读取一个字符
2 一次读取都个字符
练习
字符缓冲输入流
字符缓冲输入流 读数据
字符缓冲输出流
字符缓冲输出流 写数据
因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- stra.cn 版权所有 赣ICP备2024042791号-4
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务