文本文件的读取方式二
2015-07-01 11:16
281 查看
package collection;
import java.io.*;
import java.util.*;
public class Demo1 {
/**
* @param args
* @throws IOException
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("F:\\demo.txt");
char[] buf = new char[1024];
int num = 0;
while((num = fr.read(buf))!=-1){
sop(new String(buf,0,num));
}
}
private static void sop(Object string) {
System.out.println(string);
}
}
import java.io.*;
import java.util.*;
public class Demo1 {
/**
* @param args
* @throws IOException
* @throws IOException
*/
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("F:\\demo.txt");
char[] buf = new char[1024];
int num = 0;
while((num = fr.read(buf))!=-1){
sop(new String(buf,0,num));
}
}
private static void sop(Object string) {
System.out.println(string);
}
}
相关文章推荐
- SIFT特征点算法源码分析(opencv)
- 【Hibernate】字符串形式的数字如何正确的比较大小
- 客户端连接SQL报"Cannot Generate SSPI Context"错误
- listview当选中某一个item时设置背景色其他的不变
- Ueditor 单独使用上传图片及上传附件方法
- SQL Server 索引和视图
- Ubuntu下ftp登陆530错误
- code::blocks(版本10.05) 配置opencv2.4.3
- Combinations
- Fragment中使用出现的java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
- 调研VxWorks漏洞数据库
- Java - Why multiple inheritances are not supported in Java
- TCP连接(Time_Wait、Close_Wait)说明
- 面试题12:打印1到最大的n位数
- SQL Server 事务、异常和游标
- redis 资料链接
- Synergy安装及使用方法
- 算法---行列递增矩阵的查找
- 速查手册
- windows10正式版什么时候发布?win10正式版下周可能泄露!