org.eclipse.rdf4j.common.io

## Class FileUtil

- java.lang.Object
- - org.eclipse.rdf4j.common.io.FileUtil

-     public class FileUtil
      extends Object

  Utility methods for operations on Files.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `copyFile(File source, File destination)` Deprecated.
    `static void` | `createDirIfNotExists(File dir)` Deprecated.
    `static File` | `createTempDir(String prefix)` Deprecated. use `Files.createTempDirectory(String, java.nio.file.attribute.FileAttribute...)` instead
    `static boolean` | `deleteChildren(File directory)` Deprecated.
    `static void` | `deleteDir(File dir)` Deletes the specified directory and any files and directories in it recursively.
    `static boolean` | `deleteFiles(File directory)` Deprecated.
    `static boolean` | `deltree(File directory)` Deprecated.
    `static String` | `getFileExtension(String fileName)` Deprecated.
    `static File` | `getRelativeFile(File subj, File relativeTo)` Deprecated.
    `static String` | `getRelativePath(File subj, File relativeTo)` Deprecated.
    `static boolean` | `isLegalFileName(String fileName)` Deprecated.
    `static boolean` | `isLegalFileNameChar(char c)` Deprecated.
    `static boolean` | `moveRecursive(File from, File to, Collection<File> excludes)` Deprecated.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FileUtil

          public FileUtil()

  - ### Method Detail

    - #### getRelativePath

          @Deprecated
          public static String getRelativePath(File subj,
                                                           File relativeTo)

      Deprecated.
      Gets the relative representations of a file compared to another.
      Parameters:
        `subj` - The File to find the relative form for.
        `relativeTo` - The File 'subj' should be made relative to.
      Returns:
        The relative representation of subj.

    - #### getRelativeFile

          @Deprecated
          public static File getRelativeFile(File subj,
                                                         File relativeTo)

      Deprecated.
      Gets the relative representations of a file compared to another.
      Parameters:
        `subj` - The File to find the relative form for.
        `relativeTo` - The File 'subj' should be made relative to.
      Returns:
        The relative representation of subj.

    - #### getFileExtension

          @Deprecated
          public static String getFileExtension(String fileName)

      Deprecated.
      Gets the extension of the specified file name.
      Parameters:
        `fileName` - A file name.
      Returns:
        The file name extension (e.g. "exe" or "txt"), or `null` if the file name does not have a (valid) extension.

    - #### isLegalFileName

          @Deprecated
          public static boolean isLegalFileName(String fileName)

      Deprecated.
      Checks whether the specified file name is a legal (DOS/Windows-) file name.
      Parameters:
        `fileName` - name of the file
      Returns:
        true if all characters of the name are legal to use

    - #### isLegalFileNameChar

          @Deprecated
          public static boolean isLegalFileNameChar(char c)

      Deprecated.
      Checks whether the specified character is a legal (DOS/Windows-) file name character.
      Parameters:
        `c` - character to check
      Returns:
        true if character is legal to use

    - #### copyFile

          @Deprecated
          public static void copyFile(File source,
                                                  File destination)
                                           throws IOException

      Deprecated.
      Copies the contents of file `source` to file `destination`.
      Parameters:
        `source` - source file
        `destination` - destination file
      Throws:
        `IOException`

    - #### createDirIfNotExists

          @Deprecated
          public static void createDirIfNotExists(File dir)
                                                       throws IOException

      Deprecated.
      Creates a directory if it doesn't exist yet.
      Parameters:
        `dir` - The directory to create.
      Throws:
        `IOException` - If the creation of the directory failed.

    - #### deltree

          @Deprecated
          public static boolean deltree(File directory)

      Deprecated.
      Deletes a directory, recursively deleting all the files and subdirectories in it, or just a file.
      Parameters:
        `directory` - file or directory to delete
      Returns:
        true if all files were deleted successfully.

    - #### deleteFiles

          @Deprecated
          public static boolean deleteFiles(File directory)

      Deprecated.
      Deletes all files in the specified directory. Nothing happens when the specified File is not a directory.
      Parameters:
        `directory` -
      Returns:
        true when all files in the specified directory were successfully deleted, when there where no files or when the specified file was not a directory.

    - #### deleteChildren

          @Deprecated
          public static boolean deleteChildren(File directory)

      Deprecated.
      Deletes all files and subdirectories in the specified directory. Nothing happens when the specified File is not a directory.
      Parameters:
        `directory` -
      Returns:
        true when all children were successfully deleted, when there were no children or when the file was not a directory.

    - #### moveRecursive

          @Deprecated
          public static boolean moveRecursive(File from,
                                                          File to,
                                                          Collection<File> excludes)

      Deprecated.
      Moves the given file and all files under it (if it's a directory) to the given location, excluding the given collection of File objects!
      Parameters:
        `from` - File or directory to be moved
        `to` - The file or directory to rename to
        `excludes` - The File objects to be excluded; if a directory is excluded, all files under it are excluded as well!
      Returns:
        Whether moving was successful

    - #### createTempDir

          @Deprecated
          public static File createTempDir(String prefix)
                                                throws IOException

      Deprecated. use `Files.createTempDirectory(String, java.nio.file.attribute.FileAttribute...)` instead
      Creates a new and empty directory in the default temp directory using the given prefix.
      Parameters:
        `prefix` - The prefix string to be used in generating the directory's name; must be at least three characters long.
      Returns:
        A newly-created empty directory.
      Throws:
        `IOException` - If no directory could be created.

    - #### deleteDir

          public static void deleteDir(File dir)
                                throws IOException

      Deletes the specified directory and any files and directories in it recursively.
      Parameters:
        `dir` - The directory to remove.
      Throws:
        `IOException` - If the directory could not be removed.

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.