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;
public class MLogPlainTextFile extends MLogTarget {
- protected String file = null;
+ protected Path file = null;
protected BufferedWriter buffer = null;
/* */
- public MLogPlainTextFile(String file) throws MLoggingException {
+ public MLogPlainTextFile(Path file) throws MLoggingException {
super();
//
- if (MText.isBlank(file)) {
- throw new IllegalArgumentException("Invalid 'file': null or empty.");
+ if (null == file) {
+ throw new IllegalArgumentException("Invalid 'file': null.");
}
//
this.file = file;
try {
- this.buffer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.getFile(), true), MConstants.TEXT_ENCODING));
+ this.buffer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(this.getFile().toFile(), true), MConstants.TEXT_ENCODING));
}
catch (FileNotFoundException exception) {
throw new MLoggingException("Could not open file.", exception);
/* File. */
- protected String getFile() {
+ protected Path getFile() {
return this.file;
}
import java.io.IOException;
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
+import java.nio.file.Path;
import java.util.LinkedHashMap;
import java.util.Locale;
this.messages = messages;
}
- public MTranslator(Locale basicLocale, String file) throws MTranslationFileParsingException {
+ public MTranslator(Locale basicLocale, Path file) throws MTranslationFileParsingException {
this(basicLocale);
//
this.parseFile(file);
return this.messages;
}
- public void parseFile(String file) throws MTranslationFileParsingException {
- if (MText.isBlank(file)) {
- throw new IllegalArgumentException("Invalid 'file': null or empty.");
+ public void parseFile(Path file) throws MTranslationFileParsingException {
+ if (null == file) {
+ throw new IllegalArgumentException("Invalid 'file': null.");
}
//
try (
- LineNumberReader buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file), MConstants.TEXT_ENCODING));
+ LineNumberReader buffer = new LineNumberReader(new InputStreamReader(new FileInputStream(file.toFile()), MConstants.TEXT_ENCODING));
) {
String message = null;
String line = null;