org.mortbay.util

Class FileResource

public class FileResource extends URLResource

File Resource. Handle resources of implied or explicit file type. This class can check for aliasing in the filesystem (eg case insensitivity). By default this is turned on if the platform does not have the "/" path separator, or it can be controlled with the "org.mortbay.util.FileResource.checkAliases" system parameter. If alias checking is turned on, then aliased resources are treated as if they do not exist, nor can they be created.

Version: $Revision: 1.31 $

Author: Greg Wilkins (gregw)

Method Summary
ResourceaddPath(String path)
booleandelete()
Deletes the given resource
Stringencode(String uri)
Encode according to this resource type.
booleanequals(Object o)
booleanexists()
Returns true if the resource exists.
URLgetAlias()
static booleangetCheckAliases()
getCheckAliases.
FilegetFile()
Returns an File representing the given resource or NULL if this is not possible.
InputStreamgetInputStream()
Returns an input stream to the resource
StringgetName()
Returns the name of the resource
OutputStreamgetOutputStream()
Returns an output stream to the resource
inthashCode()
booleanisDirectory()
Returns true if the respresenetd resource is a container/directory.
longlastModified()
Returns the last modified time
longlength()
Return the length of the resource
String[]list()
Returns a list of resources contained in the given resource
booleanrenameTo(Resource dest)
Rename the given resource
static voidsetCheckAliases(boolean checkAliases)
setCheckAliases.

Method Detail

addPath

public Resource addPath(String path)

delete

public boolean delete()
Deletes the given resource

encode

public String encode(String uri)
Encode according to this resource type. File URIs are encoded.

Parameters: uri URI to encode.

Returns: The uri unchanged.

equals

public boolean equals(Object o)

Parameters: o

Returns:

exists

public boolean exists()
Returns true if the resource exists.

getAlias

public URL getAlias()

getCheckAliases

public static boolean getCheckAliases()
getCheckAliases.

Returns: True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.

getFile

public File getFile()
Returns an File representing the given resource or NULL if this is not possible.

getInputStream

public InputStream getInputStream()
Returns an input stream to the resource

getName

public String getName()
Returns the name of the resource

getOutputStream

public OutputStream getOutputStream()
Returns an output stream to the resource

hashCode

public int hashCode()

Returns: the hashcode.

isDirectory

public boolean isDirectory()
Returns true if the respresenetd resource is a container/directory.

lastModified

public long lastModified()
Returns the last modified time

length

public long length()
Return the length of the resource

list

public String[] list()
Returns a list of resources contained in the given resource

renameTo

public boolean renameTo(Resource dest)
Rename the given resource

setCheckAliases

public static void setCheckAliases(boolean checkAliases)
setCheckAliases.

Parameters: checkAliases True of resource aliases are to be checked for (eg case insensitivity or 8.3 short names) and treated as not found.

Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.