public static void genDir() {
String fileName = "date.bat";
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(fileName));
String dateStr = "";
dateStr = br.readLine();
if (dateStr != null && dateStr.split("-").length == 3) {
//date.bat内容为 2015-04-14
String year = dateStr.split("-")[0];
String month = dateStr.split("-")[1];
String day = dateStr.split("-")[2];
//默认在E盘创建目录
String dirPath = "e:\\"+year+"\\"+month+"\\"+day+"\\";
System.out.println(dirPath);
File file = new File(dirPath);
File parent = file.getParentFile();
if (parent != null && !parent.exists()) {
parent.mkdirs();
} else {
file.createNewFile();
}
file.mkdir();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}