Package org.red5.server.util
Class FileUtil
java.lang.Object
org.red5.server.util.FileUtil
Generic file utility containing useful file or directory manipulation functions.
- Author:
- Paul Gregoire (mondain@gmail.com), Dominick Accattato (daccattato@gmail.com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
copy
(InputStream in, OutputStream out) copy.static void
copyFile.static void
copyFile.static boolean
deleteDirectory
(String directory) Deletes a directory and its contents.static String
formatPath
(String absWebappsPath, String contextDirName) Quick-n-dirty directory formatting to support launching in windows, specifically from ant.static String
Generates a custom name containing numbers and an underscore ex. 282818_00023.static boolean
makeDirectory
(String directory) Create a directory.static boolean
makeDirectory
(String directory, boolean createParents) Create a directory.static void
moveFile.static byte[]
readAsByteArray
(File localSwfFile) Reads all the bytes of a given file into an array.static void
Rename a file natively; using REN on Windows and mv on *nix.static void
Unzips a war file to an application located under the webapps directory
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
copyFile
copyFile.
- Parameters:
source
- aFile
objectdest
- aFile
object- Throws:
IOException
- if any.
-
copyFile
copyFile.
- Parameters:
source
- aString
objectdest
- aString
object- Throws:
IOException
- if any.
-
moveFile
moveFile.
- Parameters:
source
- aString
objectdest
- aString
object- Throws:
IOException
- if any.
-
deleteDirectory
Deletes a directory and its contents. This will fail if there are any file locks or if the directory cannot be emptied.- Parameters:
directory
- directory to delete- Returns:
- true if directory was successfully deleted; false if directory did not exist
- Throws:
IOException
- if directory cannot be deleted
-
rename
Rename a file natively; using REN on Windows and mv on *nix.- Parameters:
from
- old nameto
- new name
-
makeDirectory
Create a directory.- Parameters:
directory
- directory to make- Returns:
- whether a new directory was made
- Throws:
IOException
- if directory does not already exist or cannot be made
-
makeDirectory
Create a directory. The parent directories will be created if createParents is passed as true.- Parameters:
directory
- directorycreateParents
- whether to create all parents- Returns:
- true if directory was created; false if it already existed
- Throws:
IOException
- if we cannot create directory
-
unzip
Unzips a war file to an application located under the webapps directory- Parameters:
compressedFileName
- The String name of the war filedestinationDir
- The destination directory, ie: webapps
-
copy
copy.
- Parameters:
in
- aInputStream
objectout
- aOutputStream
object- Throws:
IOException
- if any.
-
formatPath
Quick-n-dirty directory formatting to support launching in windows, specifically from ant.- Parameters:
absWebappsPath
- abs webapps pathcontextDirName
- conext directory name- Returns:
- full path
-
generateCustomName
Generates a custom name containing numbers and an underscore ex. 282818_00023. The name contains current seconds and a random number component.- Returns:
- custom name
-
readAsByteArray
Reads all the bytes of a given file into an array. If the file size exceeds Integer.MAX_VALUE, it will be truncated.- Parameters:
localSwfFile
- swf file- Returns:
- file bytes
-