Improved default UTF-8 charset used.

This commit is contained in:
Christian P. MOMON 2021-12-29 15:58:04 +01:00
parent 62815f6d1e
commit 5d3e05d6f1
11 changed files with 13 additions and 21 deletions

View file

@ -161,7 +161,7 @@ public class CrawlJournalFile
PrintWriter out = null;
try
{
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
write(out, source);
}
finally

View file

@ -69,7 +69,7 @@ public class EditoPage
FileUtils.copyDirectory(editoDirectory, htmlizeDirectory);
// Load body edito xhtml file.
edito = FileUtils.readFileToString(editoFile, "UTF-8");
edito = FileUtils.readFileToString(editoFile, StandardCharsets.UTF_8);
edito = XidynUtils.extractBodyContent(edito);
}
else

View file

@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
@ -57,7 +58,7 @@ public class CSVWriter implements SpreadsheetWriter
public CSVWriter(final File file, final char separator) throws UnsupportedEncodingException, FileNotFoundException
{
this.separator = separator;
this.out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
this.out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
this.isNewline = true;
}

View file

@ -41,6 +41,7 @@ import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.metrics.http.HttpAccessLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.http.HttpErrorLogAnalyzer;
import fr.devinsy.statoolinfos.metrics.minetest.MinetestProber;
import fr.devinsy.statoolinfos.metrics.mumble.MumbleProber;
import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathProperty;
import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
@ -54,8 +55,6 @@ public class Prober
{
private static Logger logger = LoggerFactory.getLogger(Prober.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
public static final Pattern YEAR_PATTERN = Pattern.compile("^\\d{4}$");
/**
@ -155,11 +154,11 @@ public class Prober
if (types.containsAnyIgnoreCase("Mumble"))
{
logger.info("== Processing Mumble.");
String source = configuration.getProbeHttpErrorLogSource();
String source = configuration.get("conf.probe.mumble.logs");
logger.info("source=[{}]", source);
// PathCounters data = HttpErrorLogAnalyzer.probe(source);
// counters.putAll(data);
PathCounters data = MumbleProber.probe(source);
counters.putAll(data);
}
// Filter.

View file

@ -31,6 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.metrics.IpCounters;
import fr.devinsy.statoolinfos.metrics.PathCounters;
import fr.devinsy.statoolinfos.util.FilesUtils;
import fr.devinsy.statoolinfos.util.LineIterator;
@ -42,8 +43,6 @@ public class HttpAccessLogAnalyzer
{
private static Logger logger = LoggerFactory.getLogger(HttpAccessLogAnalyzer.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
// log_format combined '$remote_addr - $remote_user [$time_local] '
// '"$request" $status $body_bytes_sent '
// '"$http_referer" "$http_user_agent"';

View file

@ -41,8 +41,6 @@ public class HttpErrorLogAnalyzer
{
private static Logger logger = LoggerFactory.getLogger(HttpErrorLogAnalyzer.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
public static final Pattern NGINX_ERROR_PATTERN = Pattern.compile("^(?<time>\\S+\\s\\S+)\\s\\[(?<level>[^\\]]*)\\]\\s.*$");
public static final Pattern APACHE_ERROR_PATTERN = Pattern.compile("^\\[(?<time>[^\\]]+)\\]\\s\\[(?<level>[^\\]]*)\\]\\s(?<message>.*)$");

View file

@ -33,8 +33,6 @@ public class HttpLogIterator
{
private static Logger logger = LoggerFactory.getLogger(HttpLogIterator.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
private long errorCount;
private LineIterator iterator;

View file

@ -28,8 +28,6 @@ public class NGinxLogAnalyzer
{
private static Logger logger = LoggerFactory.getLogger(NGinxLogAnalyzer.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
/**
* Instantiates a new n ginx log analyzer.
*/

View file

@ -289,7 +289,7 @@ public class PathPropertyUtils
PrintWriter out = null;
try
{
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
write(out, source);
}
finally

View file

@ -158,7 +158,7 @@ public class UptimeJournalFile
PrintWriter out = null;
try
{
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8));
write(out, source);
}
finally

View file

@ -23,6 +23,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.zip.GZIPInputStream;
import org.apache.commons.io.IOUtils;
@ -36,8 +37,6 @@ public class LineIterator
{
private static Logger logger = LoggerFactory.getLogger(LineIterator.class);
public static final String DEFAULT_CHARSET_NAME = "UTF-8";
private BufferedReader in;
private String nextLine;
private boolean ready;
@ -58,7 +57,7 @@ public class LineIterator
}
else
{
this.in = new BufferedReader(new InputStreamReader(new FileInputStream(source), DEFAULT_CHARSET_NAME));
this.in = new BufferedReader(new InputStreamReader(new FileInputStream(source), StandardCharsets.UTF_8));
}
this.nextLine = null;