/** * Description: 保存最后更新时间<br> * * @author ZhuPJ * @version 0.1 2012-5-30 void */ private void saveLastUpdTime() { if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { } } lastUpdTime = new Date(); FileUtils.write(file, String.valueOf(lastUpdTime.getTime())); }
static { String path = System.getProperty("user.dir"); // // 初始化信息,jar包路径,记录文件名 // URL url = TimerDeptHandle.class.getProtectionDomain().getCodeSource().getLocation(); // String path = url.getPath(); file = new File(path, filename); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { } } String time = FileUtils.readFile(file); if (StringUtils.isEmpty(time)) { // 无数据时,默认半年前 lastUpdTime = DateUtils.add(new Date(), Calendar.MONTH, -6); FileUtils.write(file, String.valueOf(lastUpdTime.getTime())); } else { // 有数据时,作为最后更新时间 lastUpdTime = new Date(Long.valueOf(time.trim())); } }
@Override public boolean print(File content) throws IOException { String s = FileUtils.readFile(content); return ps.print(s, this); }