import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;public class fileLoad {
public static void main(String[] args) throws Exception{
String delpath="D:\\Program Files\\apache-tomcat-6.0.20\\webapps\\workorder\\fileStorage\\documentItemStorage\\X0090241";
deletefile(delpath);
}
public static void deletefile(String delpath) {
File file = new File(delpath);
if (!file.isDirectory()) {
//file.delete();
}
else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
// File delfile = new File(delpath + "\\\\\\\\" + filelist[i]);
// if (!delfile.isDirectory())
// delfile.delete();
// else if (delfile.isDirectory()) System.out.print( filelist[i]);
getCreateTime(delpath+"\\"+"0107.XLS");
System.out.println("my printer-----"+(delpath+"\\"+"0107.XLS").toString());
deletefile(delpath + "\\\\\\\\" + filelist[i]);
}
// file.delete();
}
}
public static void getCreateTime(String filePath){
// String filePath = "C:\\test.txt";
String strTime = null;
try {
Process p = Runtime.getRuntime().exec("cmd /C dir "
+ filePath
+ "/tc" );
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while((line=br.readLine()) != null){ //这里开始就跳出了。结果strTime为null.高人指点。
if(line.endsWith(".doc")){
strTime = line.substring(0,17);
break;
}
else if(line.endsWith(".XLS")){
strTime = line.substring(0,17);
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("创建时间 " + strTime);
//输出:创建时间 2009-08-17 10:21
}
}
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;public class fileLoad {
public static void main(String[] args) throws Exception{
String delpath="D:\\Program Files\\apache-tomcat-6.0.20\\webapps\\workorder\\fileStorage\\documentItemStorage\\X0090241";
deletefile(delpath);
}
public static void deletefile(String delpath) {
File file = new File(delpath);
if (!file.isDirectory()) {
//file.delete();
}
else if (file.isDirectory()) {
String[] filelist = file.list();
for (int i = 0; i < filelist.length; i++) {
// File delfile = new File(delpath + "\\\\\\\\" + filelist[i]);
// if (!delfile.isDirectory())
// delfile.delete();
// else if (delfile.isDirectory()) System.out.print( filelist[i]);
getCreateTime(delpath+"\\"+"0107.XLS");
System.out.println("my printer-----"+(delpath+"\\"+"0107.XLS").toString());
deletefile(delpath + "\\\\\\\\" + filelist[i]);
}
// file.delete();
}
}
public static void getCreateTime(String filePath){
// String filePath = "C:\\test.txt";
String strTime = null;
try {
Process p = Runtime.getRuntime().exec("cmd /C dir "
+ filePath
+ "/tc" );
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
while((line=br.readLine()) != null){ //这里开始就跳出了。结果strTime为null.高人指点。
if(line.endsWith(".doc")){
strTime = line.substring(0,17);
break;
}
else if(line.endsWith(".XLS")){
strTime = line.substring(0,17);
break;
}
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("创建时间 " + strTime);
//输出:创建时间 2009-08-17 10:21
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货