Klasse Utils.FileUtils

java.lang.Object
net.risingworld.api.utils.Utils.FileUtils
Umschließende Klasse:
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.
  • Felddetails

    • ROOT_DIR

      public static final String ROOT_DIR
  • Konstruktordetails

    • FileUtils

      public FileUtils()
  • Methodendetails

    • writeStringToFile

      public static boolean writeStringToFile(String text, File file)
      Writes a string to file. This overrides the current file content.
      Parameter:
      text - the text you want to write to a file.
      file - the target file.
      Gibt zurück:
      true if the text was written to the file successfully, false if not.
      Example: Write String to txt file in the plugin directory
      1File targetFile = new File(getPath() + "data.txt");
      2Utils.FileUtils.writeStringToFile("Hello World!", targetFile);
    • readStringFromFile

      public static String readStringFromFile(File file)
      Reads a text / string from a file.
      Parameter:
      file - the target file.
      Gibt zurück:
      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.
      Parameter:
      bytes - the bytes you want to write to a file.
      file - the target file.
      Gibt zurück:
      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.
      Parameter:
      file - the target file.
      Gibt zurück:
      the file as a byte array.
    • getMd5

      public static String getMd5(File file)
      Gets the MD5 hash of a file.
      Parameter:
      file - the target file.
      Gibt zurück:
      the MD5 hash as a string, or null if no such file was found.