首页 相关文章 java读文件

java读文件

  

/* Readfile.java
读取文件的内容,并将原样输出至屏幕上
使用方法:java Readfile 文件名
*/
import java.io.*;
public class Readfile
{
public static void main(String[] args)
{
byte[] buff = new byte[1024];
boolean cont = true;
FileInputStream infile = null;
// 生成对象infile 准备读取文件
try
{
infile = new FileInputStream(args[0]);
}
catch (FileNotFoundException e)
{
System.err.println("没有找到文件");
System.exit(1);
}
while (cont)
{
try
{
int n = infile.read(buff); // 从文件读取数据
Sys...[ 查看全文 ]

2016-02-19 标签:

java读文件的相关文章

手机页面
收藏网站 回到头部