sendFile.java
980 字节
package com.tianbo.common;
import java.io.File;
import com.tianbo.util.PropertiesUtils;
public class sendFile {
public void move(String fileName,String path) {
// String fileName="e://xmlBean.xml";
// String endPath = "d://";
try {
File startFile = new File(fileName);
File tmpFile = new File(path);//获取文件夹路径
if(!tmpFile.exists()){//判断文件夹是否创建,没有创建则创建新文件夹
tmpFile.mkdirs();
}
System.out.println(path + startFile.getName());
if (startFile.renameTo(new File(path + startFile.getName()))) {
System.out.println("File is moved successful!");
} else {
System.out.println("File is failed to move!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
// public static void main(String[] args) {
// new sendFile().move("d://xmlBean.xml","e:/");
// }
}