| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package restcontroller.sale.cashbill;
- import beans.parameter.Parameter;
- import com.alibaba.fastjson2.JSONArray;
- import com.alibaba.fastjson2.JSONObject;
- import common.YosException;
- import common.data.Row;
- import common.data.Rows;
- import java.io.*;
- import java.nio.charset.StandardCharsets;
- import java.util.*;
- public class TxtFactory {
- private String filename;
- public static String filetype = "txt";
- String filepath = "";
- public TxtFactory(String filename) throws YosException {
- this.filename = filename + Calendar.getInstance().getTimeInMillis();
- String var10001 = Parameter.getExcelExportPath();
- this.filepath = var10001 + "/" + this.filename + "." + filetype;
- }
- public void write(String str) throws YosException {
- try {
- PrintWriter out = new PrintWriter(
- new OutputStreamWriter(
- new FileOutputStream(this.filepath),
- "GBK"
- )
- );
- // 写入文本
- out.println(str);
- // 确保所有缓冲的输出都被写出
- out.flush();
- // 关闭PrintWriter,虽然在这个例子中System.out不需要显式关闭
- out.close();
- out.flush();
- } catch (IOException var16) {
- var16.printStackTrace();
- }
- }
- public String getFilename() {
- return this.filename + "." + filetype;
- }
- public String getFilepath() {
- return this.filepath;
- }
- public File getFile() throws YosException {
- return new File(this.filepath);
- }
- public void deletefile() {
- File file = new File(this.filepath);
- file.delete();
- }
- }
|