想必这个曲线你们都认识,这是遗忘曲线,展现人的记忆会随着时间的延长慢慢遗忘的规律,同时还展现了若是咱们过一段时间复习一次对遗忘的有利影响.java
道理你们都懂,关键怎么作到?小程序
靠在本子上记下今天我该复习哪一天的知识?或者手机上设定一个提醒?....app
不,这些方法都太麻烦又难受了,由于光安排复习时间,就得让你写很长时间,并且复习的时候还得对照它们再去找对应的笔记.ui
今天我就跟你们分享一款我根据遗忘曲线本身开发的一款java小程序:spa
只要你告诉它首尾日期和磁盘地址,它就给你生成有规律的复习计划,像这样:code
打开20190325.doc里面是这样的:orm
仔细看,里面日期的规律,前一天,前3天,前7天,前15天.......blog
对!反遗忘复习规律就在这里!!!ip
废话很少说,下面给你们分享代码:开发
=======================================================
package com.huawei.it.helloworld;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author 一马平川1
* @date 2019/2/19 23:02
* @description
*/
public class BatchCreateNoteFiles {
private static final int ADD_ONE_DAY = 1 ;
public static void main(String[] args) throws IOException, ParseException {
BatchCreateNoteFiles batchCreateNoteFiles = new BatchCreateNoteFiles();
//按以下格式填入起止日期和生成文件的磁盘地址
batchCreateNoteFiles.createFile("20190220","20200220","E:\\MyNotes\\");
}
//生成文件
public void createFile(String startDate,String endDate,String location) throws ParseException, IOException {
String prefix = location;
String suffix = ".doc";
SimpleDateFormat f = new SimpleDateFormat("yyyyMMdd");
String fileName = startDate;
while (Integer.parseInt(fileName) <= Integer.parseInt(endDate)){
File file = new File(prefix+fileName+suffix);
//给文件写入内容
initFile(file,fileName,f);
Calendar instance = Calendar.getInstance();
instance.setTime(f.parse(fileName));
instance.add(Calendar.DAY_OF_MONTH,BatchCreateNoteFiles.ADD_ONE_DAY);
fileName = f.format(instance.getTime());
}
}
//给文件写入内容(文件内容初始化)
private void initFile(File file, String fileName, SimpleDateFormat f) throws IOException, ParseException {
FileOutputStream fs = new FileOutputStream(file);
fs.write(getInitContent(fileName,f).getBytes());
}
//获取文件初始化内容
private String getInitContent(String fileName, SimpleDateFormat f) throws ParseException {
Date noteDate = f.parse(fileName);
Calendar instance = Calendar.getInstance();
instance.setTime(noteDate);
StringBuilder sb = new StringBuilder("[");
//获取1天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001);
sb.append(f.format(instance.getTime())).append("]-[");
//获取3天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 1);
sb.append(f.format(instance.getTime())).append("]-[");
//获取7天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 2);
sb.append(f.format(instance.getTime())).append("]-[");
//获取15天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 3);
sb.append(f.format(instance.getTime())).append("]-[");
//获取31天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 4);
sb.append(f.format(instance.getTime())).append("]-[");
//获取63天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 5);
sb.append(f.format(instance.getTime())).append("]-[");
//获取127天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 6);
sb.append(f.format(instance.getTime())).append("]-[");
//获取255天以前的日期
instance.add(Calendar.DAY_OF_MONTH,-0x0000001 << 7);
sb.append(f.format(instance.getTime())).append("]");
return sb.toString();
}
}
=======================================================================
本小程序的功能目标是:能自动给文档中初始化的日期内容添加上各自的超连接,这样就不用手动添加超连接了,若是你知道怎么操做,请大侠留言,谢谢!
本小程序接下来将利用Swing作一个亲和的界面,固然这不是重点,主要是更人性化一些.
此外,本博主想问问:怎么将java小程序封装成能双击启动的EXE程序?若是能这样,那这个小程序就很完美了!
大侠,请留下您宝贵的建议!