package iotest.javase.test;
import java.io.*;
//单个读取
public class testio_03 {
public static void main(String[] args) throws IOException {
//第一步:定义要输出文件的File类对象
File file = new File("F:/io/hehe.java");
//第二部:实例化IputStream类对象.
InputStream ips=new FileInputStream(file);
//第三部:实现数组读取操作
byte data[]=new byte[1024];
int foot = 0;//控制保存的脚标索引
int temp = 0;//接受每次保存的字节数据
do{ //读取一次
temp=(byte)ips.read();
if (temp != -1) {//表示现在有数据
data[foot ++]=(byte)temp;
}
}while(temp != -1);//表示后面可能还有数据
System.out.println("读取的内容:【"+new String(data)+"】");//输出要打印的东西
//System.out.println("读取的内容:【"+new String(data,0,len)+"】");//上面读取全部,下面将部分读取并不是全部读取
//第四步:关比流,关比资源
ips.close();
}
}
import java.io.*;
//单个读取
public class testio_03 {
public static void main(String[] args) throws IOException {
//第一步:定义要输出文件的File类对象
File file = new File("F:/io/hehe.java");
//第二部:实例化IputStream类对象.
InputStream ips=new FileInputStream(file);
//第三部:实现数组读取操作
byte data[]=new byte[1024];
int foot = 0;//控制保存的脚标索引
int temp = 0;//接受每次保存的字节数据
do{ //读取一次
temp=(byte)ips.read();
if (temp != -1) {//表示现在有数据
data[foot ++]=(byte)temp;
}
}while(temp != -1);//表示后面可能还有数据
System.out.println("读取的内容:【"+new String(data)+"】");//输出要打印的东西
//System.out.println("读取的内容:【"+new String(data,0,len)+"】");//上面读取全部,下面将部分读取并不是全部读取
//第四步:关比流,关比资源
ips.close();
}
}