1、日期格式化
Date date=new Date();
//转换成时间格式12小时制
SimpleDateFormat df_12=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //转换成时间格式24小时制
SimpleDateFormat df_24=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); System.out.println("12小时制时间::"+df_12.format(date));
System.out.println("24小时制时间::"+df_24.format(date)); 2、过滤文件名非法字符
private static Pattern FilePattern = Pattern.compile("[\\\\/:*?\"<>|]");
public static String filenameFilter(String str) {
return str==null?null:FilePattern.matcher(str).replaceAll("");
} 3、读取文件内容
public static String readFile(String filePath) throws Exception{
File file = new File(filePath);
BufferedReader in = null;
String result = "";
String str = "";
try {
in = new BufferedReader(new FileReader(file));
while((str = in.readLine()) != null){
result += str;
}
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}

最新文章

  1. C#的委托
  2. [LeetCode] Palindrome Number 验证回文数字
  3. 移动端web app自适应布局探索与总结
  4. UVa11324 The Largest Clique(强连通分量+缩点+记忆化搜索)
  5. Java 14 类型信息
  6. java反射机制浅谈
  7. WPF样式——多条件触发器
  8. IE7下position:relative的问题
  9. 运行批处理bat文件不出现黑框
  10. js多物体任意值运动
  11. 读书笔记—CLR via C#线程25-26章节
  12. Java Reference 源码分析
  13. Java字符串String
  14. C++11并发——多线程std::mutex (二)
  15. 管理 Oracle Cluster Registry(OCR)
  16. Delphi的程序单元、结构、基础知识(转)
  17. OPML文件
  18. vim相关命令单独记载
  19. tp3.2和Bootstrap模态框导入excel表格数据
  20. python教程(一)&#183;python环境搭建

热门文章

  1. css一些事儿
  2. ironic state information
  3. virt-install command
  4. vue 自定义过度组件用法
  5. [ecmanget][常用标签]bookmark
  6. php中普通方法和静态方法的区别以及抽象类和接口
  7. 破解navicat
  8. Android React Native组件的生命周期及回调函数
  9. IO多路复用的理解
  10. HDU 6165 FFF at Valentine(Tarjan缩点+拓扑排序)