Class Utils.FileUtils

java.lang.Object
net.risingworld.api.utils.Utils.FileUtils
Enclosing class:
Utils

public abstract static class Utils.FileUtils extends Object
Contains various file function, including file access, reading or writing to files, or getting the md5 checksum of a file.
  • Field Details

    • ROOT_DIR

      public static final String ROOT_DIR
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • writeStringToFile

      public static boolean writeStringToFile(String text, File file)
      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.
    • readStringFromFile

      public static String readStringFromFile(File file)
      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

      public static boolean writeBytesToFile(byte[] bytes, File file)
      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

      public static byte[] readBytesFromFile(File file)
      Reads the bytes of a file.
      Parameters:
      file - the target file.
      Returns:
      the file as a byte array.
    • getMd5

      public static String getMd5(File file)
      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.