From: Marco Zanon <info@marcozanon.com>
Date: Wed, 9 Aug 2023 16:12:43 +0000 (+0000)
Subject: Switched from String to Path.
X-Git-Tag: 8.0.0~4
X-Git-Url: https://gitweb.marcozanon.com/?a=commitdiff_plain;h=f8603ee45a3df96329500ed48a38cfda0c7746a1;p=Macaco

Switched from String to Path.
---

diff --git a/src/main/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java b/src/main/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java
index eb6a1f9..38756c2 100644
--- a/src/main/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java
+++ b/src/main/java/com/marcozanon/macaco/logging/MLogPlainTextFile.java
@@ -14,27 +14,28 @@ 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;
 
 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);
@@ -55,7 +56,7 @@ public class MLogPlainTextFile extends MLogTarget {
 
     /* File. */
 
-    protected String getFile() {
+    protected Path getFile() {
         return this.file;
     }
 
diff --git a/src/main/java/com/marcozanon/macaco/text/MTranslator.java b/src/main/java/com/marcozanon/macaco/text/MTranslator.java
index 7e67d8a..114da26 100644
--- a/src/main/java/com/marcozanon/macaco/text/MTranslator.java
+++ b/src/main/java/com/marcozanon/macaco/text/MTranslator.java
@@ -14,6 +14,7 @@ import java.io.InputStreamReader;
 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;
 
@@ -41,7 +42,7 @@ public class MTranslator extends MObject {
         this.messages = messages;
     }
 
-    public MTranslator(Locale basicLocale, String file) throws MTranslationFileParsingException {
+    public MTranslator(Locale basicLocale, Path file) throws MTranslationFileParsingException {
         this(basicLocale);
         //
         this.parseFile(file);
@@ -64,13 +65,13 @@ public class MTranslator extends MObject {
         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;