public static void main(String[] args) throws Exception {
//创建文件输入流对象,定义输入文件地址
FileInputStream fileInputStream = new FileInputStream("D:\\stu/bbb.txt");
//创建文件输出流对象,定义文件地址
FileOutputStream fileOutputStream = new FileOutputStream("D:\\stu/ccc.txt", false);
//定义缓冲区buf,字节长度为1k
byte[] buf = new byte[1024];
//定义count,接收读取字节长度
int count = 0;
//while循环读取字节流
while ((count = fileInputStream.read(buf)) != -1) {
//写入文件输出地址,使用count去指定写入长度
fileOutputStream.write(buf, 0, count);
}
//关闭文件输出流对象FileOutputStream对象
fileInputStream.close();
fileOutputStream.close();
}