java_文件复制
来源:互联网 发布:chrome js调用本地exe 编辑:程序博客网 时间:2024/06/05 09:15
mport java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class Copy {
public static void main(String[] args){
if(args.length!=2){
System.out.println("输入参数不正确.");
System.out.println("例:java copy 源文件路径,目标文件路径");
System.exit(1);
}
File f1=new File(args[0]);
File f2=new File(args[1]);
if(!f1.exists()){
System.out.println("源文件不出在");
System.exit(1);
}
InputStream input=null;
OutputStream out=null;
try{
input=new FileInputStream(f1);
}
catch(FileNotFoundException e){
e.printStackTrace();
}
try{
out=new FileOutputStream(f2);
}
catch (FileNotFoundException e) {
e.printStackTrace();
// TODO: handle exception
}
if(input!=null && out!=null){
int temp=0;
try{
while ((temp=input.read())!=-1) {
out.write(temp);
}
System.out.println("复制完成");
}catch(IOException e){
e.printStackTrace();
System.out.println("复制失败");
}
try{
input.close();
out.close();
}
catch (IOException e) {
e.printStackTrace();
// TODO: handle exception
}
}
}
}
- java_文件复制
- java_复制文件及目录到另一个盘下
- JAVA_如何复制项目
- JAVA_读写文件
- java_文件解压
- Java_打开/保存文件
- Java_打开/保存文件
- Java_读取xml文件;
- Java_ .classpath 文件
- Java_读写CSV文件
- Java_读取properties文件
- java_之读取属性文件
- java_获取文件中的文件名
- java_文件输入与输出
- Java_基础—拷贝文件
- Java_集合操作_复制list到另一list中
- Java_文件的分割与合并
- Java_文件上传与下载(一)
- ActionScript 3中自定义命名空间——封装的实现
- win7上安装vs2010报错:microsoft 应用程序错误报告[解决方法]
- 编写TaskMgr.exe的时候学习的知识点
- 黑马程序员--SQL Server 中实现类似Split的字符串分割函数
- php中使用header函数后,页面提示:Warnging: Cannot modify header information - headers already sent by 错误的的原因
- java_文件复制
- 操作系统(Linux/Windows)中解决的问题记录
- git快捷入门 常用命令
- 托盘图标的现实(利用类)
- 存储集合元素的List转换为Map
- 安装完IIS localhost打不开
- Oracle PL SQL :TIPS
- 多边形bool操作效率对比
- 不同方法求解两个数的最大公约数代码