org.ckkloverdos.resource
Class FileResource

java.lang.Object
  extended by org.ckkloverdos.resource.FileResource
All Implemented Interfaces:
IResource, IToStringAware

public class FileResource
extends java.lang.Object
implements IResource, IToStringAware

File-based resource.

Author:
Christos KK Loverdos

Constructor Summary
FileResource(java.io.File file)
          Constructs a new instance from the given file.
FileResource(java.lang.String name)
          Constructs a new instance from the given file name.
 
Method Summary
 boolean exists()
          Returns true iff the resource exists.
 java.io.File getFile()
          Returns the file object for this resource.
 java.io.InputStream getInputStream()
          Returns a new FileInputStream constructed from the resource file.
 java.lang.String getName()
          Returns the file name of this resource.
 java.net.URL getURL()
          Returns the URL representation of the resource file.
 boolean isDirectory()
          Returns true iff the resource is a directory.
 boolean isFile()
          Returns true iff the resource is a file.
 java.lang.String toString()
           
 void toStringAware(ToString ts)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileResource

public FileResource(java.io.File file)
Constructs a new instance from the given file.

Parameters:
file -

FileResource

public FileResource(java.lang.String name)
Constructs a new instance from the given file name.

Parameters:
name -
Method Detail

exists

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

Specified by:
exists in interface IResource

isFile

public boolean isFile()
Returns true iff the resource is a file. This always returns true for a FileResource. You should consult exists() to see if the file exists.

Specified by:
isFile in interface IResource

isDirectory

public boolean isDirectory()
Returns true iff the resource is a directory.


getFile

public java.io.File getFile()
Returns the file object for this resource.

Specified by:
getFile in interface IResource

getName

public java.lang.String getName()
Returns the file name of this resource.

Specified by:
getName in interface IResource

getURL

public java.net.URL getURL()
Returns the URL representation of the resource file. This is equivalent to getFile().toURL().

Specified by:
getURL in interface IResource

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns a new FileInputStream constructed from the resource file.

Specified by:
getInputStream in interface IResource
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toStringAware

public void toStringAware(ToString ts)
Specified by:
toStringAware in interface IToStringAware


Copyright © 1999-2007 Christos KK Loverdos. All Rights Reserved.