OutPutMsg.java 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package cn.com.lzt.personnelbasearchivesmanage.util;
  2. import java.io.BufferedWriter;
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.io.FileNotFoundException;
  6. import java.io.FileOutputStream;
  7. import java.io.IOException;
  8. import java.io.InputStream;
  9. import java.io.OutputStreamWriter;
  10. import java.text.SimpleDateFormat;
  11. import java.util.Date;
  12. import java.util.Map;
  13. import java.util.UUID;
  14. import org.jeecgframework.core.util.FileUtils;
  15. import org.jeecgframework.core.util.ResourceUtil;
  16. import org.springframework.util.FileCopyUtils;
  17. import cn.com.lzt.common.entity.TSysFileEntity;
  18. /**
  19. * 员工基本档案导入日志
  20. * @author zbw
  21. * 2018-1-11
  22. */
  23. public class OutPutMsg {
  24. /**
  25. * @author zbw
  26. * 2018-1-11
  27. * @param args
  28. */
  29. public static void main(String[] args) {
  30. // TODO Auto-generated method stub
  31. }
  32. /**
  33. * 先把日志进行本地存储;
  34. * @author zbw
  35. * 2018-1-15
  36. * @param toPath
  37. * @param fileName
  38. * @param msg
  39. */
  40. public static void writeMsgTxT(String toPath,String fileName,String msg) {
  41. // SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyy-MM-dd HH:mm:ss ms");
  42. // System.out.println(visitorIp+"--"+simpleDateFormat.format(new Date()));
  43. File fileVal =new File(toPath+fileName);
  44. //如果文件夹不存在则创建
  45. // if (!fileVal.exists() && !fileVal.isDirectory()) {
  46. //// System.out.println("//不存在");
  47. // File fileVal2 =new File(toPathPart);
  48. // if (!fileVal2.exists() && !fileVal2.isDirectory()) {
  49. // fileVal.mkdirs();
  50. // }else{
  51. // fileVal.mkdir();
  52. // }
  53. // }
  54. try
  55. {
  56. FileOutputStream out = new FileOutputStream(fileVal,true);
  57. BufferedWriter bw = new BufferedWriter(
  58. new OutputStreamWriter(out));
  59. if(msg.indexOf(";")!=-1){
  60. for (int i = 0; i < msg.split(";").length; i++) {
  61. bw.write(msg.split(";")[i]+";");
  62. bw.newLine();
  63. }
  64. }else{
  65. bw.write(msg);
  66. bw.newLine();
  67. }
  68. bw.flush();
  69. bw.close();
  70. }
  71. catch (FileNotFoundException e) {
  72. e.printStackTrace();
  73. }
  74. catch (IOException e) {
  75. e.printStackTrace();
  76. }
  77. }
  78. public static void writeMsgXls(Map<String, Object> fileMsgMap) {
  79. }
  80. }