|
@@ -2,6 +2,7 @@ package com.gis.common.util;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -14,8 +15,12 @@ import java.util.regex.Matcher;
|
|
|
public class FileUtils {
|
|
|
|
|
|
public static void writeUtf8String(final Object content, final String filePath) {
|
|
|
- String data = JSON.toJSONStringWithDateFormat(content, "yyyy-MM-dd HH:mm:ss");
|
|
|
- //清空所有域名
|
|
|
+ String data = JSON.toJSONStringWithDateFormat(
|
|
|
+ content,
|
|
|
+ "yyyy-MM-dd HH:mm:ss",
|
|
|
+ SerializerFeature.WriteNullListAsEmpty, // 将 null 的 List 输出为 []
|
|
|
+ SerializerFeature.WriteNullStringAsEmpty // 将 null 的 String 输出为 ""
|
|
|
+ ); //清空所有域名
|
|
|
data = getStringReplaceUrl(data);
|
|
|
FileUtil.writeUtf8String(data, filePath.replaceAll("/", Matcher.quoteReplacement(File.separator)));
|
|
|
}
|