Package org.apache.wicket.util.file
Class File
- java.lang.Object
-
- java.io.File
-
- org.apache.wicket.util.file.File
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<java.io.File>,IModifiable
- Direct Known Subclasses:
Folder
public class File extends java.io.File implements IModifiable
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description File(java.io.File file)Construct.File(java.io.File parent, java.lang.String child)Construct.File(java.lang.String pathname)Constructor.File(java.lang.String parent, java.lang.String child)Constructor.File(java.net.URI uri)Constructor.File(File parent, java.lang.String child)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Filefile(java.lang.String name)java.lang.StringgetExtension()FoldergetParentFolder()java.io.InputStreaminputStream()TimelastModifiedTime()Returns a Time object representing the most recent time this file was modified.java.io.OutputStreamoutputStream()Creates a buffered output stream that writes to this file.java.lang.ObjectreadObject()java.lang.StringreadString()booleanremove()voidsync()Force contents of file to physical storagejava.lang.StringtoQuotedString()intwrite(java.io.InputStream input)Writes the given input stream to this filevoidwrite(java.lang.String string)Write the given string to this fileintwrite(File file)Writes the given file to this onevoidwriteObject(java.io.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 Detail
-
File
public File(File parent, java.lang.String child)
Constructor.- Parameters:
parent- parentchild- child
-
File
public File(java.io.File parent, java.lang.String child)Construct.- Parameters:
parent- parentchild- child
-
File
public File(java.io.File file)
Construct.- Parameters:
file- File from java.io package
-
File
public File(java.lang.String pathname)
Constructor.- Parameters:
pathname- path name
-
File
public File(java.lang.String parent, java.lang.String child)Constructor.- Parameters:
parent- parentchild- child
-
File
public File(java.net.URI uri)
Constructor.- Parameters:
uri- file uri
-
-
Method Detail
-
file
public File file(java.lang.String name)
- Parameters:
name- Name of child file- Returns:
- Child file object
-
getExtension
public java.lang.String getExtension()
- Returns:
- File extension (whatever is after the last '.' in the file name)
-
getParentFolder
public Folder getParentFolder()
- Returns:
- Parent folder
-
inputStream
public java.io.InputStream inputStream() throws java.io.FileNotFoundException- Returns:
- Input stream that reads this file
- Throws:
java.io.FileNotFoundException- Thrown if the file cannot be found
-
lastModifiedTime
public Time lastModifiedTime()
Returns a Time object representing the most recent time this file was modified.- Specified by:
lastModifiedTimein interfaceIModifiable- Returns:
- This file's lastModified() value as a Time object or
nullif that information is not available
-
outputStream
public java.io.OutputStream outputStream() throws java.io.FileNotFoundExceptionCreates 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:
java.io.FileNotFoundException- Thrown if the file cannot be found
-
readString
public java.lang.String readString() throws java.io.IOException- Returns:
- String read from this file
- Throws:
java.io.IOException
-
readObject
public java.lang.Object readObject() throws java.io.IOException, java.lang.ClassNotFoundException- Returns:
- Object read from serialization file
- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeObject
public void writeObject(java.io.Serializable object) throws java.io.IOException- Parameters:
object- Object to write to this file- Throws:
java.io.IOException
-
remove
public boolean remove()
- Returns:
- True if the file was removed
- See Also:
File.delete()
-
sync
public void sync() throws java.io.IOExceptionForce contents of file to physical storage- Throws:
java.io.IOException
-
toQuotedString
public java.lang.String toQuotedString()
- Returns:
- This file in double quotes (useful for passing to commands and tools that have issues with spaces in filenames)
-
write
public int write(File file) throws java.io.IOException
Writes the given file to this one- Parameters:
file- The file to copy- Returns:
- number of bytes written
- Throws:
java.io.IOException
-
write
public int write(java.io.InputStream input) throws java.io.IOExceptionWrites the given input stream to this file- Parameters:
input- The input- Returns:
- Number of bytes written
- Throws:
java.io.IOException
-
write
public void write(java.lang.String string) throws java.io.IOExceptionWrite the given string to this file- Parameters:
string- The string to write- Throws:
java.io.IOException
-
-