Xindice API

org.apache.xindice.server
Interface FileResource


public interface FileResource

FileResource represents and provides a manipulation interface to Xindice's abstracted FileManager.


Method Summary
 void copyStreamTo(java.io.OutputStream os)
          copyStreamTo copies the data of this FileResource to the specified OutputStream.
 boolean delete()
          delete deletes the file specified by this object.
 boolean exists()
          exists tests if this File exists
 java.lang.String getAbsolutePath()
          getAbsolutePath returns the absolute pathname of the file represented by this object.
 java.io.OutputStream getAppendStream()
          getAppendStream returns an OutputStream for appending to the FileResource.
 java.lang.String getCanonicalPath()
          getCanonicalPath Returns the canonical form of this File object's pathname.
 FileResource[] getChildren()
          getChildren returns a list of the files in the directory specified by this FileResource.
 java.io.InputStream getInputStream()
          getInputStream returns an InputStream for reading the FileResource.
 java.lang.String getName()
          getName returns the name of the file represented by this object.
 java.io.OutputStream getOutputStream()
          getOutputStream returns an OutputStream for overwriting the FileResource.
 java.lang.String getPath()
          getPath returns the pathname of the file represented by this object.
 boolean isDirectory()
          isDirectory tests if the file represented by this FileResource is a directory.
 boolean isFile()
          isFile tests if the file represented by this FileResource is a "normal" file.
 long lastModified()
          lastModified Returns the time that the file represented by this FileResource was last modified.
 long length()
          length returns the length of the file represented by this File object.
 boolean mkdir()
          mkdir creates a directory whose pathname is specified by this FileResource.
 boolean mkdirs()
          mkdirs creates a directory whose pathname is specified by this FileResource, including any necessary parent directories.
 boolean move(java.lang.String filename)
          move moves the file specified by this FileResource to the pathname given by the filename argument.
 boolean rename(java.lang.String filename)
          rename renames the file specified by this FileResource to have the pathname given by the filename argument.
 

Method Detail

getInputStream

public java.io.InputStream getInputStream()
getInputStream returns an InputStream for reading the FileResource.
Returns:
the InputStream

getOutputStream

public java.io.OutputStream getOutputStream()
getOutputStream returns an OutputStream for overwriting the FileResource.
Returns:
the OutputStream

getAppendStream

public java.io.OutputStream getAppendStream()
getAppendStream returns an OutputStream for appending to the FileResource.
Returns:
the OutputStream.

copyStreamTo

public void copyStreamTo(java.io.OutputStream os)
                  throws java.io.IOException
copyStreamTo copies the data of this FileResource to the specified OutputStream.
Parameters:
os - the OutputStream

move

public boolean move(java.lang.String filename)
move moves the file specified by this FileResource to the pathname given by the filename argument.
Parameters:
filename - the new filename
Returns:
true if the move succeeds

rename

public boolean rename(java.lang.String filename)
rename renames the file specified by this FileResource to have the pathname given by the filename argument.
Parameters:
filename - the new filename
Returns:
true if the renaming succeeds

getChildren

public FileResource[] getChildren()
getChildren returns a list of the files in the directory specified by this FileResource.
Returns:
an array of FileResources that are children of this FileResource

getName

public java.lang.String getName()
getName returns the name of the file represented by this object. The name is everything in the pathame after the last occurrence of the separator character.
Returns:
the name of the file (without any directory components)

getPath

public java.lang.String getPath()
getPath returns the pathname of the file represented by this object.
Returns:
the pathname represented by this FileResource

getAbsolutePath

public java.lang.String getAbsolutePath()
getAbsolutePath returns the absolute pathname of the file represented by this object. If this object represents an absolute pathname, then return the pathname. Otherwise, return a pathname that is a concatenation of the current user directory, the separator character, and the pathname of this FileResource.
Returns:
a system-dependent absolute pathname for this File

getCanonicalPath

public java.lang.String getCanonicalPath()
                                  throws java.io.IOException
getCanonicalPath Returns the canonical form of this File object's pathname. The precise definition of canonical form is system-dependent, but it usually specifies an absolute pathname in which all relative references and references to the current user directory have been completely resolved. The canonical form of a pathname of a nonexistent file may not be defined.
Returns:
a system-dependent absolute pathname for this FileResource
Throws:
java.io.IOException - If an I/O error occurs

exists

public boolean exists()
exists tests if this File exists
Returns:
true if the file specified by this object exists

isFile

public boolean isFile()
isFile tests if the file represented by this FileResource is a "normal" file. A file is "normal" if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.
Returns:
true if the file specified by this object exists and is a "normal" file

isDirectory

public boolean isDirectory()
isDirectory tests if the file represented by this FileResource is a directory.
Returns:
true if this File exists and is a directory

lastModified

public long lastModified()
lastModified Returns the time that the file represented by this FileResource was last modified. The return value is system dependent and should only be used to compare with other values returned by last modified. It should not be interpreted as an absolute time.
Returns:
the time the file specified by this object was last modified

length

public long length()
length returns the length of the file represented by this File object.
Returns:
the length, in bytes, of the file specified by this object

mkdir

public boolean mkdir()
mkdir creates a directory whose pathname is specified by this FileResource.
Returns:
true if the directory could be created

mkdirs

public boolean mkdirs()
mkdirs creates a directory whose pathname is specified by this FileResource, including any necessary parent directories.
Returns:
true if the directory (or directories) could be created

delete

public boolean delete()
delete deletes the file specified by this object. If the target file to be deleted is a directory, it must be empty for deletion to succeed.
Returns:
true if the file is successfully deleted

Xindice API

Copyright (c) 1999-2001 The Apache Software Foundation