Package org.apache.wicket.util.file
Class File
java.lang.Object
java.io.File
org.apache.wicket.util.file.File
- All Implemented Interfaces:
Serializable
,Comparable<File>
,IModifiable
- Direct Known Subclasses:
Folder
Simple extension of File that adds an implementation of IModifiable for files. This allows the
ModificationWatcher class to watch files for modification. The IModifiable.lastModifiedTime()
method also returns a Time object with a more convenient API than either Date or a value in
milliseconds.
- Author:
- Jonathan Locke
- See Also:
-
Field Summary
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns a Time object representing the most recent time this file was modified.Creates a buffered output stream that writes to this file.boolean
remove()
void
sync()
Force contents of file to physical storageint
write
(InputStream input) Writes the given input stream to this filevoid
Write the given string to this fileint
Writes the given file to this onevoid
writeObject
(Serializable object) Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
-
Constructor Details
-
File
Constructor.- Parameters:
parent
- parentchild
- child
-
File
Construct.- Parameters:
parent
- parentchild
- child
-
File
Construct.- Parameters:
file
- File from java.io package
-
File
Constructor.- Parameters:
pathname
- path name
-
File
Constructor.- Parameters:
parent
- parentchild
- child
-
File
Constructor.- Parameters:
uri
- file uri
-
-
Method Details
-
file
- Parameters:
name
- Name of child file- Returns:
- Child file object
-
getExtension
- Returns:
- File extension (whatever is after the last '.' in the file name)
-
getParentFolder
- Returns:
- Parent folder
-
inputStream
- Returns:
- Input stream that reads this file
- Throws:
FileNotFoundException
- Thrown if the file cannot be found
-
lastModifiedTime
Returns a Time object representing the most recent time this file was modified.- Specified by:
lastModifiedTime
in interfaceIModifiable
- Returns:
- This file's lastModified() value as a Time object or
null
if that information is not available
-
outputStream
Creates a buffered output stream that writes to this file. If the parent folder does not yet exist, creates all necessary folders in the path.- Returns:
- Output stream that writes to this file
- Throws:
FileNotFoundException
- Thrown if the file cannot be found
-
readString
- Returns:
- String read from this file
- Throws:
IOException
-
readObject
- Returns:
- Object read from serialization file
- Throws:
IOException
ClassNotFoundException
-
writeObject
- Parameters:
object
- Object to write to this file- Throws:
IOException
-
remove
- Returns:
- True if the file was removed
- See Also:
-
sync
Force contents of file to physical storage- Throws:
IOException
-
toQuotedString
- Returns:
- This file in double quotes (useful for passing to commands and tools that have issues with spaces in filenames)
-
write
Writes the given file to this one- Parameters:
file
- The file to copy- Returns:
- number of bytes written
- Throws:
IOException
-
write
Writes the given input stream to this file- Parameters:
input
- The input- Returns:
- Number of bytes written
- Throws:
IOException
-
write
Write the given string to this file- Parameters:
string
- The string to write- Throws:
IOException
-