package com.bjnsc.ssis.util;
import com.bjnsc.ssis.document.user.constant.ConstantPool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
@Slf4j
public class CharConvertHtmlUtil {
private volatile static CharConvertHtmlUtil singleton = new CharConvertHtmlUtil();
private CharConvertHtmlUtil() {
}
public static CharConvertHtmlUtil getInstance() {
return singleton;
}
public void char2Html(String str, String modelName) throws Exception {
String path = "src/main/resources/template";
File fileDoc = new File(path);
if (!fileDoc.exists()) {
fileDoc.mkdirs();
}
String htmlAbsolutePath = fileDoc.getAbsolutePath();
File outFile = new File(htmlAbsolutePath+ "/" + modelName + ".html");
BufferedWriter output = null;
try {
output = new BufferedWriter(new FileWriter(outFile));
output.write(str);
} catch (
IOException e) {
e.printStackTrace();
} finally {
try {
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
|