package io;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class BasicIO {
//
public static void main(String[] args) {
try{
int temp=-1;
FileInputStream in = new FileInputStream("F://eclipseWorkStation//temp//basicIO1.txt");
FileOutputStream os = new FileOutputStream("F://eclipseWorkStation//temp//to//basicIO1.txt");
while((temp=in.read())!=-1){
os.write(temp);
}
}catch(Exception e){
}
}
}
int read() 读取的是实际字节的十进制值。
本文提供了一个Java基本输入输出操作的示例代码,演示了如何使用FileInputStream和FileOutputStream进行文件复制。通过读取源文件的每个字节并写入目标文件,实现了简单有效的文件内容复制。
920

被折叠的 条评论
为什么被折叠?



