public class Test1_6_1 {
public static void main(String[] args) throws IOException {
FileInputStream fis = null;
FileOutputStream fos = null;
try{
//1开流
fis = new FileInputStream("a.txt");
fos = new FileOutputStream("b.txt");
//定义一个变量,用于接收字节
int b = 0;
//循环,结束条件为读取结果为-1
while ((b = fis.read()) != -1) {
fos.write(b);
}
} finally {
try {
//关流
if (fis != null)
fis.close();
} finally {
if (fos != null)
fos.close();
}
}
}
}| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |