Class FileUtilities

java.lang.Object
ml.karmaconfigs.api.common.utils.file.FileUtilities

public class FileUtilities extends Object
Karma file utilities
  • Field Details

    • DEBUG

      public static boolean DEBUG
      Enable debug
  • Constructor Details

    • FileUtilities

      public FileUtilities()
  • Method Details

    • create

      public static void create(@NotNull @NotNull File file)
      Create a file
      Parameters:
      file - the file to create
    • createWithException

      public static void createWithException(@NotNull @NotNull File file) throws IOException
      Create a file and catch any exception
      Parameters:
      file - the file to create
      Throws:
      IOException - any exception
    • createWithResults

      public static boolean createWithResults(@NotNull @NotNull File file)
      Create a file and return if the file could be created
      Parameters:
      file - the file to create
      Returns:
      if the file could be created
    • destroy

      public static void destroy(@NotNull @NotNull File file)
      Deletes a file
      Parameters:
      file - the file to delete
    • destroyWithException

      public static void destroyWithException(@NotNull @NotNull File file) throws IOException
      Deletes a file and catch any exception
      Parameters:
      file - the file to delete
      Throws:
      IOException - any exception
    • destroyWithResults

      public static boolean destroyWithResults(@NotNull @NotNull File file)
      Deletes a file and return if the file could be created
      Parameters:
      file - the file to delete
      Returns:
      if the file could be created
    • isKarmaFile

      public static boolean isKarmaFile(File file)
      Get if the file is a karma file
      Parameters:
      file - the file
      Returns:
      if the file is a karma file
    • isValidFile

      public static boolean isValidFile(File file)
      Get if the file is valid
      Parameters:
      file - the file
      Returns:
      if the file is a valid file
    • isValidFile

      public static boolean isValidFile(String path)
      Get if the file is a valid file
      Parameters:
      path - the file
      Returns:
      if the file is a valid file
    • getParentFile

      public static String getParentFile(@NotNull @NotNull File file)
      Get the file
      Parameters:
      file - the file
      Returns:
      the file
    • getFile

      public static String getFile(File file)
      Get the file path
      Parameters:
      file - the file path
      Returns:
      the file path
    • getPrettyParentFile

      public static String getPrettyParentFile(@NotNull @NotNull File file)
      Get the pretty file
      Parameters:
      file - the file
      Returns:
      the pretty file
    • getPrettyFile

      public static String getPrettyFile(File file)
      Get the pretty file path
      Parameters:
      file - the file
      Returns:
      the pretty file path
    • getParentFile

      public static String getParentFile(@NotNull @NotNull File file, char barReplace)
      Get the parent file replacing %20 ( space char )
      Parameters:
      file - the file
      barReplace - the %20 replace
      Returns:
      the parent file
    • getFile

      public static String getFile(@NotNull @NotNull File file, char barReplace)
      Get the file replacing the %20 ( space char )
      Parameters:
      file - the file
      barReplace - the %20 replace
      Returns:
      the file
    • getExtension

      public static String getExtension(@NotNull @NotNull File file)
      Get the file extension
      Parameters:
      file - the file
      Returns:
      the file extension
    • getExtension

      public static String getExtension(@NotNull @NotNull String name)
      Get the file extension
      Parameters:
      name - the file name
      Returns:
      the file extension
    • findParents

      public static String[] findParents(String fileString)
      Find parent files on a file string
      Parameters:
      fileString - the file string
      Returns:
      the file string parent directories
    • clearParents

      public static String clearParents(String fileString)
      Clear parent files on a file string
      Parameters:
      fileString - the files string
      Returns:
      the file string without parent files
    • getName

      public static String getName(@NotNull @NotNull File file, boolean extension)
      Get the file name
      Parameters:
      file - the file name
      extension - include extension
      Returns:
      the file name
    • getFileType

      public static String getFileType(File file)
      Get the file type
      Parameters:
      file - the file tpy
      Returns:
      the file type
    • getFileCompleteType

      public static String getFileCompleteType(File file)
      Get the file complete type
      Parameters:
      file - the file complete type
      Returns:
      the file type
    • readAllLines

      public static List<String> readAllLines(File file)
      Read all the file lines
      Parameters:
      file - the file
      Returns:
      all the file lines
    • getSourceFile

      public static File getSourceFile(KarmaSource source)
      Get the karma source jar file
      Parameters:
      source - the karma source
      Returns:
      the source jar file
    • getFixedFile

      public static File getFixedFile(@NotNull @NotNull File file)
      Fix a file
      Parameters:
      file - the file
      Returns:
      the fixed file
    • getProjectFolder

      public static File getProjectFolder(String delimiter)
      Get the project folder
      Parameters:
      delimiter - the project complete path delimiter
      Returns:
      the project folder
    • getProjectParent

      public static File getProjectParent()
      Get the project parent folder
      Returns:
      the project parent folder
    • getProjectFolder

      @Deprecated public static File getProjectFolder(KarmaSource source)
      Deprecated.
      Get the project folder
      Parameters:
      source - the source
      Returns:
      the project folder