Package net.risingworld.api.utils
Class Utils.FileUtils
java.lang.Object
net.risingworld.api.utils.Utils.FileUtils
- Enclosing class:
Utils
Contains various file function, including file access, reading or writing
to files, or getting the md5 checksum of a file.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Gets the MD5 hash of a file.static byte[]
readBytesFromFile
(File file) Reads the bytes of a file.static String
readStringFromFile
(File file) Reads a text / string from a file.static boolean
writeBytesToFile
(byte[] bytes, File file) Writes bytes to a file.static boolean
writeStringToFile
(String text, File file) Writes a string to file.
-
Field Details
-
ROOT_DIR
-
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
writeStringToFile
Writes a string to file. This overrides the current file content.- Parameters:
text
- the text you want to write to a file.file
- the target file.- Returns:
- true if the text was written to the file successfully, false
if not.
- Example: Write String to txt file in the plugin directory
-
readStringFromFile
Reads a text / string from a file.- Parameters:
file
- the target file.- Returns:
- the string that was read from the file, or null if no such file was found.
-
writeBytesToFile
Writes bytes to a file. This overrides the current file content.- Parameters:
bytes
- the bytes you want to write to a file.file
- the target file.- Returns:
- true if the bytes were written to the file successfully, false if not.
-
readBytesFromFile
Reads the bytes of a file.- Parameters:
file
- the target file.- Returns:
- the file as a byte array.
-
getMd5
Gets the MD5 hash of a file.- Parameters:
file
- the target file.- Returns:
- the MD5 hash as a string, or null if no such file was found.
-