/**
* @author xiaobuding93
* @date 2015/05/31
* @function 实现了简单的文件复制的功能,将本文件复制到target.txt
*/
//使用了java的字节流,边读边写
import java.io.*;
public class MyIODemo02 {
public static void main(String args[]){
try{
FileInputStream fis = new FileInputStream(new File("MyIODemo02.java"));
FileOutputStream fos = new FileOutputStream(new File("target.txt"));
byte b[] = new byte[128];
System.out.println("文件一共有"+new File("MyIODemo02.java").length() + "B");
while(fis.read(b)!=-1){
fos.write(b);
//System.out.println(b.toString());
}
fis.close();
fos.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
JAVA IO的一点尝试1
最新推荐文章于 2022-12-20 15:38:18 发布