复制粘贴的例子:
import java.io.*;
public class CopyPaste{
public static void main(String[] args) throws IOException{
copy();
}
public static void copy() throws IOException {
//读取文件
InputStream readin = new BufferedInputStream(new FlieInputStream("D:\\lzz\\11\\22.txt"));
//新建对象,输出读取到的内容到新文件,paste.txt不存在的话会自动创建paste.txt。
OuputStream paste = new BufferedOutputStream("D:\\lzz\\qiao\\paste.txt");
//输出读取到的内容到新文件
int data;
while((data = readin.read()) != -1){
paste.write(data);
}
//关闭资源
readin.close();
paste.colse();
}
}