org.apache.wicket.util.file
Class File

java.lang.Object
  extended by java.io.File
      extended by org.apache.wicket.util.file.File
All Implemented Interfaces:
Serializable, Comparable<File>, IModifiable
Direct Known Subclasses:
Folder

public class File
extends 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

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
File(File file)
          Construct.
File(File parent, String child)
          Constructor.
File(File parent, String child)
          Construct.
File(String pathname)
          Constructor.
File(String parent, String child)
          Constructor.
File(URI uri)
          Constructor.
 
Method Summary
 String getExtension()
           
 Folder getParentFolder()
           
 Time lastModifiedTime()
          Returns a Time object representing the most recent time this file was modified.
 String readString()
           
 boolean remove()
           
 void sync()
          Force contents of file to physical storage
 void write(File file)
          Writes the given file to this one
 int write(InputStream input)
          Writes the given input stream to this file
 void write(String string)
          Write the given string to this file
 
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, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

File

public File(File parent,
            String child)
Constructor.

Parameters:
parent - parent
child - child

File

public File(File parent,
            String child)
Construct.

Parameters:
parent -
child -

File

public File(File file)
Construct.

Parameters:
file - File from java.io package

File

public File(String pathname)
Constructor.

Parameters:
pathname - path name

File

public File(String parent,
            String child)
Constructor.

Parameters:
parent - parent
child - child

File

public File(URI uri)
Constructor.

Parameters:
uri - file uri
Method Detail

getExtension

public String getExtension()
Returns:
File extension (whatever is after the last '.' in the file name)

getParentFolder

public Folder getParentFolder()
Returns:
Parent folder

lastModifiedTime

public final Time lastModifiedTime()
Returns a Time object representing the most recent time this file was modified.

Specified by:
lastModifiedTime in interface IModifiable
Returns:
This file's lastModified() value as a Time object

readString

public final String readString()
                        throws IOException
Returns:
String read from this file
Throws:
IOException

remove

public boolean remove()
Returns:
True if the file was removed
See Also:
File.delete()

sync

public void sync()
          throws IOException
Force contents of file to physical storage

Throws:
IOException

write

public final void write(File file)
                 throws IOException
Writes the given file to this one

Parameters:
file - The file to copy
Throws:
IOException

write

public final int write(InputStream input)
                throws IOException
Writes the given input stream to this file

Parameters:
input - The input
Returns:
Number of bytes written
Throws:
IOException

write

public final void write(String string)
                 throws IOException
Write the given string to this file

Parameters:
string - The string to write
Throws:
IOException


Copyright © 2004-2011 Apache Software Foundation. All Rights Reserved.