net.jxta.search.resolver.io
Class FSDirectory

java.lang.Object
  |
  +--net.jxta.search.resolver.io.Directory
        |
        +--net.jxta.search.resolver.io.FSDirectory

public final class FSDirectory
extends Directory

Straightforward implementation of Directory as a directory of files.

See Also:
Directory

Constructor Summary
FSDirectory(java.io.File path, boolean create)
           
FSDirectory(java.lang.String path, boolean create)
           
 
Method Summary
 void close()
          Closes the store to future operations.
 Output createFile(java.lang.String name)
          Creates a new, empty file in the directory with the given name.
 void deleteFile(java.lang.String name)
          Removes an existing file in the directory.
 boolean fileExists(java.lang.String name)
          Returns true iff a file with the given name exists.
 long fileLength(java.lang.String name)
          Returns the length in bytes of a file in the directory.
static long fileModified(java.io.File directory, java.lang.String name)
          Returns the time the named file was last modified.
 long fileModified(java.lang.String name)
          Returns the time the named file was last modified.
 java.lang.String[] list()
          Returns an array of strings, one for each file in the directory.
static void main(java.lang.String[] args)
           
 Input openFile(java.lang.String name)
          Returns a stream reading an existing file.
 void renameFile(java.lang.String from, java.lang.String to)
          Renames an existing file in the directory.
 
Methods inherited from class net.jxta.search.resolver.io.Directory
readVIntFile, readVLongFile, writeVIntFile, writeVLongFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FSDirectory

public FSDirectory(java.lang.String path,
                   boolean create)
            throws java.io.IOException

FSDirectory

public FSDirectory(java.io.File path,
                   boolean create)
            throws java.io.IOException
Method Detail

list

public final java.lang.String[] list()
                              throws java.io.IOException
Returns an array of strings, one for each file in the directory.
Overrides:
list in class Directory

fileExists

public final boolean fileExists(java.lang.String name)
                         throws java.io.IOException
Returns true iff a file with the given name exists.
Overrides:
fileExists in class Directory

fileModified

public final long fileModified(java.lang.String name)
                        throws java.io.IOException
Returns the time the named file was last modified.
Overrides:
fileModified in class Directory

fileModified

public static final long fileModified(java.io.File directory,
                                      java.lang.String name)
                               throws java.io.IOException
Returns the time the named file was last modified.

fileLength

public final long fileLength(java.lang.String name)
                      throws java.io.IOException
Returns the length in bytes of a file in the directory.
Overrides:
fileLength in class Directory

deleteFile

public final void deleteFile(java.lang.String name)
                      throws java.io.IOException
Removes an existing file in the directory.
Overrides:
deleteFile in class Directory

renameFile

public final void renameFile(java.lang.String from,
                             java.lang.String to)
                      throws java.io.IOException
Renames an existing file in the directory.
Overrides:
renameFile in class Directory

createFile

public final Output createFile(java.lang.String name)
                        throws java.io.IOException
Creates a new, empty file in the directory with the given name. Returns a stream writing this file.
Overrides:
createFile in class Directory

openFile

public final Input openFile(java.lang.String name)
                     throws java.io.IOException
Returns a stream reading an existing file.
Overrides:
openFile in class Directory

close

public final void close()
                 throws java.io.IOException
Closes the store to future operations.
Overrides:
close in class Directory

main

public static void main(java.lang.String[] args)