Add a file input/output helper

This commit is contained in:
zontreck 2024-01-21 17:02:53 -07:00
parent ba02ef8f7e
commit 35f4e96805

View file

@ -0,0 +1,25 @@
package dev.zontreck.ariaslib.util;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class FileIO
{
public static String readFile(String filePath) {
try {
byte[] fileBytes = Files.readAllBytes(Paths.get(filePath));
return new String(fileBytes);
} catch (IOException e) {
return "An error occurred: " + e.getMessage();
}
}
public static void writeFile(String filePath, String newContent) {
try {
Files.write(Paths.get(filePath), newContent.getBytes());
} catch (IOException e) {
}
}
}