文件操作类

来源:互联网 发布:网络电视机那个好用 编辑:程序博客网 时间:2024/06/06 03:51

http://blog.csdn.net/lijinghua1245/article/details/56282601

File 是文件类 File file = new File(file路径);

FileInputStream ,FileOutputStream是文件流。文件流对文件操作  FileInputStream fis = new FileInputStream (file); 

有了文件流就可以对文件读,写操作


File file1=new File("D://a.xls");
FileInputStream fis=new FileInputStream(file1);
File file2=new File("D://b.xls");
FileOutputStream fos=new FileOutputStream(file2);
byte[] b=new byte[1024];
int a=0;
while((a=fis.read(b))>0){
fos.write(b);
}
fis.close();
fos.close();


D://a.xls 读取数据,写入到D://b.xls