得到指定文件的时间和大小

public String getFileTime(String filename) {
String filetime = "";
try {
Process p = Runtime.getRuntime().exec(
"cmd /C dir d:\\upload\\" + filename + " /tc");
InputStream is = p.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));

String str;
int i = 0;
while ((str = br.readLine()) != null) {
i++;
if (i == 6) {
filetime = str;

}
}

} catch (java.io.IOException exc) {
exc.printStackTrace();
}
return filetime;

}

你可能感兴趣的:(java,C++,c,C#)