package com.marcozanon.macaco;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+
public class MConstants extends MObject {
/* Generic information. */
/* Environment configuration. */
- public static final String TEXT_ENCODING = "UTF-8";
+ public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;;
/* Threads. */
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
import java.util.Date;
//
this.file = file;
try {
- this.buffer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.getFile().toFile(), true), MConstants.TEXT_ENCODING));
+ this.buffer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.getFile().toFile(), true), MConstants.DEFAULT_CHARSET));
}
catch (FileNotFoundException exception) {
throw new MLoggingException("Could not open file.", exception);
}
- catch (UnsupportedEncodingException exception) { // cannot happen
- }
}
@Override
String text = x;
//
StringBuilder fakeXhtmlPageContent = new StringBuilder("");
- fakeXhtmlPageContent.append(String.format("<?xml version=\"1.0\" encoding=\"%s\" ?>", MConstants.TEXT_ENCODING));
+ fakeXhtmlPageContent.append(String.format("<?xml version=\"1.0\" encoding=\"%s\" ?>", MConstants.DEFAULT_CHARSET));
fakeXhtmlPageContent.append("<!DOCTYPE html SYSTEM \"fake-dtd\" >");
fakeXhtmlPageContent.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
fakeXhtmlPageContent.append("<head><title /></head>");
});
//
- reader.parse(new InputSource(new ByteArrayInputStream(fakeXhtmlPageContent.toString().getBytes(MConstants.TEXT_ENCODING))));
+ reader.parse(new InputSource(new ByteArrayInputStream(fakeXhtmlPageContent.toString().getBytes(MConstants.DEFAULT_CHARSET))));
}
catch (ParserConfigurationException exception) { // cannot happen
}
}
//
try (
- LineNumberReader buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file.toFile()), MConstants.TEXT_ENCODING));
+ LineNumberReader buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file.toFile()), MConstants.DEFAULT_CHARSET));
) {
String message = null;
String line = null;