io流中的字节和字符
2015-09-13 16:27
190 查看
字节
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//使用字节流的方式读取当前你正在编辑的.java源码文件
File inputFile= new File("D:/eclipse/matengda/src/IO/TestByte.java");
//计算所读取到的字节数,并在控制台打印
//输出方法1
System.out.println(inputFile.length());
//输出方法2
FileInputStream input = new FileInputStream(inputFile);
int i = 0;
int num = 0;
while ((i = input.read()) !=-1) {
num++;
}
System.out.println(num);
这是IO流中的字节输出输入的最基本
throws IOException这是一个标示
File file = new File(" ");定义一个新的文件
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//使用字节流的方式读取当前你正在编辑的.java源码文件
File inputFile= new File("D:/eclipse/matengda/src/IO/TestByte.java");
//计算所读取到的字节数,并在控制台打印
//输出方法1
System.out.println(inputFile.length());
//输出方法2
FileInputStream input = new FileInputStream(inputFile);
int i = 0;
int num = 0;
while ((i = input.read()) !=-1) {
num++;
}
System.out.println(num);
这是IO流中的字节输出输入的最基本
throws IOException这是一个标示
File file = new File(" ");定义一个新的文件
相关文章推荐
- 201 Bitwise AND of Numbers Range
- 回溯法:字符串转换
- 什么是关系型数据库
- WM_NOTIFY Message
- 软工视频总结
- 给UITextView添加PlaceHolder
- [转]如何卸载eclipse中的ADT
- TextureView+SurfaceTexture+OpenGL ES来播放视频(一)
- 【开源项目解析】QQ“一键下班”功能实现解析——学习Path及贝塞尔曲线的基本使用
- hdu 1131 Count the Trees 卡特兰数+java
- 关系型数据库笔试面试题
- 一次上线记录
- hdu 1131 Count the Trees 卡特兰数+java
- C#在Winform中改变Textbox高度三种方法
- markdown 标记补充
- 用户注册表单验证
- java中的一些常见排序算法
- 中文man安装
- HightChart标示区(plotBands)
- hibernate3映射关联关系举例