public static void moveDataFile2Reject(String dataFilePath, String rejectFilePath) throws Exception {
File rejectFile = new File(rejectFilePath);
if(!rejectFile.exists())
rejectFile.mkdir();
File file = new File(dataFilePath);
File[] files = file.listFiles();
for (File f : files) {
if(f.isFile())
{
f.renameTo(new File(rejectFilePath + f.getName()));
}
}
}
public static void main(String[] args){
String dataFilePath = "C:/Desktop/新建文件夹";
String rejectFilePath = "C:/Desktop/新建文件夹/测试/";
try {
moveDataFile2Reject(dataFilePath, rejectFilePath);
System.out.println("更改完成");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
File rejectFile = new File(rejectFilePath);
if(!rejectFile.exists())
rejectFile.mkdir();
File file = new File(dataFilePath);
File[] files = file.listFiles();
for (File f : files) {
if(f.isFile())
{
f.renameTo(new File(rejectFilePath + f.getName()));
}
}
}
public static void main(String[] args){
String dataFilePath = "C:/Desktop/新建文件夹";
String rejectFilePath = "C:/Desktop/新建文件夹/测试/";
try {
moveDataFile2Reject(dataFilePath, rejectFilePath);
System.out.println("更改完成");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}