Java之字节输入流和输出流
2024-08-25 20:25:00
package IODemo; import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; public class OutputStreamAndInputStream { /**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
demo1();
demo2();
demo3();
} private static void demo3() throws IOException {
FileInputStream fis = new FileInputStream("Demo.txt");
byte buf[] = new byte[10];
int len = 0;
while ((len = fis.read(buf)) != -1) {
System.out.println(new String(buf, 0, len));
}
} private static void demo2() throws IOException {
FileOutputStream fos = new FileOutputStream("Demo.txt");
fos.write("abcd".getBytes());
} private static void demo1() throws IOException {
FileInputStream fis = new FileInputStream("Demo.txt");
int ch = 0;
while ((ch = fis.read()) != -1) {
System.out.println((char) ch);
}
} }
最新文章
- ORA-00942:table or view does not exist
- easyUI datagraid的列排序
- repeater 根据输入 返回汉字
- MongoVUE
- mac OS X操作 -- 常用
- c++ map 的基本操作
- Android——数据库相关(课堂整理)
- DIOCP之数据接收事件
- JSTL 核心标签库
- Http 信息头
- (7)基于hadoop的简单网盘应用实现3
- Python的多线程GIL浅谈
- lookup_peer.go
- springmvc简单的流程说明及源码分析
- Junit概述
- 调试 - Visual Studio调试
- C#实时检测端口占用情况
- 【CUDA并行程序设计系列(1)】GPU技术简介
- Spring boot发送邮件
- “取件帮”微信小程序宣传视频链接及内容介绍
热门文章
- poj The Clocks 高斯消元
- win8.1下使用vmware workstation 来编译ffmpeg
- ????????????	no permissions
- POJ 3252 Round Numbers(数位dp)
- SRM 585 DIV1 L2
- Uploadify 控件上传图片 + 预览
- 51nod水题记
- POJ 3678 Katu Puzzle (2-SAT,常规)
- LeetCode Excel Sheet Column Title (输出excel表的列名称)
- 【转】蓝牙ble app开发(三) -- 抓包