Package ch.njol.skript.util
Class FileUtils
java.lang.Object
ch.njol.skript.util.FileUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
static void
backupPurge
(File varFile, int toKeep) Deletes files in backup directory to meet desired target, starting from oldest to neweststatic void
static String
static File
static Collection
<File> static void
save
(InputStream in, File file) Saves the contents of an InputStream in a file.
-
Method Details
-
getBackupSuffix
- Returns:
- The current date and time
-
backupPurge
public static void backupPurge(File varFile, int toKeep) throws IOException, IllegalArgumentException Deletes files in backup directory to meet desired target, starting from oldest to newest- Parameters:
varFile
- Variable file in order to get 'backups' directorytoKeep
- Integer of how many files are to be left remaining- Throws:
IOException
- If 'backups' directory is not foundIllegalArgumentException
- If 'toKeep' parameter is less than 0
-
backup
- Throws:
IOException
-
move
- Throws:
IOException
-
copy
- Throws:
IOException
-
renameAll
public static Collection<File> renameAll(File directory, Converter<String, String> renamer) throws IOException- Parameters:
directory
-renamer
- Renames files. Return null to leave a file as-is.- Returns:
- A collection of all changed files (with their new names)
- Throws:
IOException
- If renaming one of the files caused an IOException. Some files might have been renamed already.
-
save
Saves the contents of an InputStream in a file.- Parameters:
in
- The InputStream to read from. This stream will not be closed when this method returns.file
- The file to save to. Will be replaced if it exists, or created if it doesn't.- Throws:
IOException
-