日期:2014-05-18 浏览次数:20714 次
//每天的文件存储在对应目录下,如1991/09/24产生的文件就存在1991/09/24目录下
for (; startTime <= stopTime; startTime = MyUtil.getTomorrow(startTime)) {
//生成父路径
parentPath = basepathOfFiles + File.separator + startTime
/ 10000 + File.separator + MyUtil.filenameFormat((startTime / 100) % 100, 2)
+ File.separator + MyUtil.filenameFormat(startTime % 100, 2);
file = new File(parentPath);
file.mkdirs();
//产生每天的小文件
for (int i = 0; i < numOfFiles; i++) {
//生成小文件名
pathOfFile = parentPath + File.separator + MyUtil.filenameFormat(i, 5)
+ ".txt";
try {
//开始写了
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(pathOfFile), "UTF-8"));
writer.write("" + startTime + MyUtil.filenameFormat(i, 3));
writer.write(cContent);
System.out.println("write " + pathOfFile + " ok!");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null) {
try {
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
//每天的文件存储在对应目录下,如1991/09/24产生的文件就存在1991/09/24目录下
for (; startTime <= stopTime; startTime = MyUtil.getTomorrow(startTime)) {
//生成父路径
parentPath = basepathOfFiles + File.separator + startTime
/ 10000 + File.separator + MyUtil.filenameFormat((startTime / 100) % 100, 2)
+ File.separator + MyUtil.filenameFormat(startTime % 100, 2);
file = new File(parentPath);
file.mkdirs();
//产生每天的小文件
for (int i = 0; i < numOfFiles; i++) {
//生成小文件名
pathOfFile = parentPath + File.separator + MyUtil.filenameFormat(i, 5)
+ ".txt";
try {
//开始写了
writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(pathOfFile), "UTF-8"));
writer.write("" + startTime + MyUtil.filenameFormat(i, 3));
writer.write(cContent);
System.out.println("write " + pathOfFile + " ok!");
} catch (Exception e) {
e.printStackTrace();
} finally {
if (writer != null)