拷贝文件
来源:互联网 发布:php oa办公系统源代码 编辑:程序博客网 时间:2024/05/16 12:06
拷贝文件:
package test;
import javax.swing.*;
import java.io.*;
publicclasstest extends JFrame{
publicstaticvoid copy(File s1,File s2){
FileInputStream f1=null;
FileOutputStream f2=null;
try{
f1=newFileInputStream(s1);
f2=new FileOutputStream(s2);
int read=-1;
while((read =f1.read())>=0){
f2.write(read);
}
}catch(Exception e){
}
finally{
try{
if(f1!=null)f1.close();
if(f2!=null)f2.close();
System.exit(0);
}catch(Exception e){
}
}
}
publicstaticvoid main(String[] args) {
File s1;
File s2;
int i=-1;
JFileChooser chooser=new JFileChooser();
i=chooser.showOpenDialog(chooser);
if(i==JFileChooser.APPROVE_OPTION)
{
s1=chooser.getSelectedFile();
i=chooser.showSaveDialog(chooser);
if(i==JFileChooser.APPROVE_OPTION){
s2=chooser.getSelectedFile();
copy(s1,s2);
}
}
}
}
- 文件拷贝
- 拷贝文件
- 拷贝文件
- 文件拷贝
- 拷贝文件
- 文件拷贝
- 文件拷贝
- 文件拷贝
- 文件拷贝
- 拷贝文件
- 文件拷贝
- 拷贝文件
- 文件拷贝
- 文件拷贝
- 文件拷贝
- 文件拷贝
- 文件拷贝
- 拷贝文件
- TeX-源文档组织结构
- 知识的深度和广度
- ARM __iomem __force
- Java Applet
- 避免ORA-04031错误与SHARED POOL调整
- 拷贝文件
- 读书笔记(2)
- 态度决定高度
- 强连通分量
- C语言中遇到的问题及解决方法
- 10700 - Camel trading
- 黑马程序员-C#基础知识
- Eclipse快捷键大全
- hibernate学习小结---hibernate的关联关系映射(Association Mappings)