Package org.apache.juneau.internal
Class FileUtils
java.lang.Object
org.apache.juneau.internal.FileUtils
File utilities.
 
See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidCreates a file if it doesn't already exist usingFile.createNewFile().static FilecreateTempFile(String name) Create a temporary file with the specified name.static FilecreateTempFile(String name, String contents) Create a temporary file with the specified name and specified contents.static booleanRecursively deletes a file or directory.static booleanReturnstrue if the specified file exists in the specified directory.static StringgetBaseName(String name) Strips the extension from a file name.static StringgetExtension(String name) Returns the extension from a file name.static StringgetFileName(String path) Given an arbitrary path, returns the file name portion of that path.static booleanhasExtension(String name, String ext) Returnstrue if the specified file name contains the specified extension.static FileSame asFile.mkdirs()except throws a RuntimeExeption if directory could not be created.static FileSame asmkdirs(String, boolean)but uses String path.static voidUpdates the modified timestamp on the specified file.
- 
Constructor Details- 
FileUtilspublic FileUtils()
 
- 
- 
Method Details- 
mkdirsSame asFile.mkdirs()except throws a RuntimeExeption if directory could not be created.- Parameters:
- f- The directory to create. Must not be- null .
- clean- If- true , deletes the contents of the directory if it already exists.
- Returns:
- The same file.
- Throws:
- RuntimeException- if directory could not be created.
 
- 
mkdirsSame asmkdirs(String, boolean)but uses String path.- Parameters:
- path- The path of the directory to create. Must not be- null 
- clean- If- true , deletes the contents of the directory if it already exists.
- Returns:
- The directory.
 
- 
deleteRecursively deletes a file or directory.- Parameters:
- f- The file or directory to delete.
- Returns:
- true if file or directory was successfully deleted.
 
- 
createCreates a file if it doesn't already exist usingFile.createNewFile().Throws a RuntimeExceptionif the file could not be created.- Parameters:
- f- The file to create.
 
- 
modifyTimestampUpdates the modified timestamp on the specified file.Method ensures that the timestamp changes even if it's been modified within the past millisecond. - Parameters:
- f- The file to modify the modified timestamp on.
 
- 
createTempFileCreate a temporary file with the specified name.The name is broken into file name and suffix, and the parts are passed to File.createTempFile(String, String).File.deleteOnExit()is called on the resulting file before being returned by this method.- Parameters:
- name- The file name
- Returns:
- A newly-created temporary file.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
createTempFileCreate a temporary file with the specified name and specified contents.The name is broken into file name and suffix, and the parts are passed to File.createTempFile(String, String).File.deleteOnExit()is called on the resulting file before being returned by this method.- Parameters:
- name- The file name
- contents- The file contents.
- Returns:
- A newly-created temporary file.
- Throws:
- IOException- Thrown by underlying stream.
 
- 
getBaseNameStrips the extension from a file name.- Parameters:
- name- The file name.
- Returns:
- The file name without the extension, or null if name wasnull .
 
- 
getExtensionReturns the extension from a file name.- Parameters:
- name- The file name.
- Returns:
- The the extension, or null if name wasnull .
 
- 
existsReturnstrue if the specified file exists in the specified directory.- Parameters:
- dir- The directory.
- fileName- The file name.
- Returns:
- true if the specified file exists in the specified directory.
 
- 
hasExtensionReturnstrue if the specified file name contains the specified extension.- Parameters:
- name- The file name.
- ext- The extension.
- Returns:
- true if the specified file name contains the specified extension.
 
- 
getFileNameGiven an arbitrary path, returns the file name portion of that path.- Parameters:
- path- The path to check.
- Returns:
- The file name.
 
 
-