123456789101112131415161718192021222324252627282930313233343536 |
- package com.steerinfo.dil.util;
- import org.apache.commons.lang.time.FastDateFormat;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.zip.CheckedOutputStream;
- public class newFileTool {
- public static int newFile(String jsonString,String type) throws IOException {
- //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd");
- String date = format.format(new Date());
- File file = new File("/shared/" + date + "-" + type + ".txt");
- //File file = new File("/shared/test.txt");
- FileWriter fileWriter = new FileWriter(file,true);
- FastDateFormat format1 = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
- fileWriter.append("\n");
- fileWriter.append(format1.format(new Date()) + "-----------------------");
- fileWriter.append("\n");
- fileWriter.append(jsonString);
- fileWriter.append("\n");
- fileWriter.append(format1.format(new Date()) + "-----------------------");
- fileWriter.append("\n");
- fileWriter.flush();
- fileWriter.close();
- System.out.println(file);
- System.out.println("文件存储完成");
- return 1;
- }
- }
|