org.eclipse.jetty.util.resource

## Class FileResource

- java.lang.Object
- - org.eclipse.jetty.util.resource.Resource
  - - org.eclipse.jetty.util.resource.URLResource
    - - org.eclipse.jetty.util.resource.FileResource

- All Implemented Interfaces:
    ResourceFactory

      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, or it can be controlled by calling the static method @see FileResource#setCheckAliases(boolean)

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.util.resource.URLResource

      `_connection, _in, _url, _urlString`

    - ### Fields inherited from class org.eclipse.jetty.util.resource.Resource

      `__defaultUseCaches`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileResource(java.net.URL url)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Resource` | `addPath(java.lang.String path)` Returns the resource contained inside the current resource with the given name
    `void` | `copyTo(java.io.File destination)`
    `boolean` | `delete()` Deletes the given resource
    `java.lang.String` | `encode(java.lang.String uri)` Encode according to this resource type.
    `boolean` | `equals(java.lang.Object o)`
    `boolean` | `exists()` Returns true if the resource exists.
    `java.net.URL` | `getAlias()`
    `static boolean` | `getCheckAliases()` getCheckAliases.
    `java.io.File` | `getFile()` Returns an File representing the given resource or NULL if this is not possible.
    `java.io.InputStream` | `getInputStream()` Returns an input stream to the resource
    `java.lang.String` | `getName()` Returns the name of the resource
    `java.io.OutputStream` | `getOutputStream()` Returns an output stream to the resource
    `int` | `hashCode()`
    `boolean` | `isDirectory()` Returns true if the respresenetd resource is a container/directory.
    `long` | `lastModified()` Returns the last modified time
    `long` | `length()` Return the length of the resource
    `java.lang.String[]` | `list()` Returns a list of resources contained in the given resource
    `boolean` | `renameTo(Resource dest)` Rename the given resource
    `static void` | `setCheckAliases(boolean checkAliases)` setCheckAliases.

    - ### Methods inherited from class org.eclipse.jetty.util.resource.URLResource

      `checkConnection, getURL, getUseCaches, isContainedIn, release, toString`

    - ### Methods inherited from class org.eclipse.jetty.util.resource.Resource

      `finalize, getAssociate, getDefaultUseCaches, getListHTML, getResource, getURI, isContainedIn, newClassPathResource, newClassPathResource, newResource, newResource, newResource, newResource, newResource, newSystemResource, setAssociate, setDefaultUseCaches, toURL, writeTo`

    - ### Methods inherited from class java.lang.Object

      `clone, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### FileResource

          public FileResource(java.net.URL url)
                       throws java.io.IOException,
                              java.net.URISyntaxException

      Throws:
        `java.io.IOException`
        `java.net.URISyntaxException`

  - ### Method Detail

    - #### 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.

    - #### 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.

    - #### addPath

          public Resource addPath(java.lang.String path)
                           throws java.io.IOException,
                                  java.net.MalformedURLException

      Description copied from class: `URLResource`
      Returns the resource contained inside the current resource with the given name
      Overrides:
        `addPath` in class `URLResource`
      Parameters:
        `path` - The path segment to add, which should be encoded by the encode method.
      Throws:
        `java.io.IOException`
        `java.net.MalformedURLException`

    - #### getAlias

          public java.net.URL getAlias()

      Overrides:
        `getAlias` in class `Resource`
      Returns:
        The canonical Alias of this resource or null if none.

    - #### exists

          public boolean exists()

      Returns true if the resource exists.
      Overrides:
        `exists` in class `URLResource`

    - #### lastModified

          public long lastModified()

      Returns the last modified time
      Overrides:
        `lastModified` in class `URLResource`

    - #### isDirectory

          public boolean isDirectory()

      Returns true if the respresenetd resource is a container/directory.
      Overrides:
        `isDirectory` in class `URLResource`

    - #### length

          public long length()

      Return the length of the resource
      Overrides:
        `length` in class `URLResource`

    - #### getName

          public java.lang.String getName()

      Returns the name of the resource
      Overrides:
        `getName` in class `URLResource`

    - #### getFile

          public java.io.File getFile()

      Returns an File representing the given resource or NULL if this is not possible.
      Overrides:
        `getFile` in class `URLResource`

    - #### getInputStream

          public java.io.InputStream getInputStream()
                                             throws java.io.IOException

      Returns an input stream to the resource
      Overrides:
        `getInputStream` in class `URLResource`
      Throws:
        `java.io.IOException`

    - #### getOutputStream

          public java.io.OutputStream getOutputStream()
                                               throws java.io.IOException,
                                                      java.lang.SecurityException

      Returns an output stream to the resource
      Overrides:
        `getOutputStream` in class `URLResource`
      Throws:
        `java.io.IOException`
        `java.lang.SecurityException`

    - #### delete

          public boolean delete()
                         throws java.lang.SecurityException

      Deletes the given resource
      Overrides:
        `delete` in class `URLResource`
      Throws:
        `java.lang.SecurityException`

    - #### renameTo

          public boolean renameTo(Resource dest)
                           throws java.lang.SecurityException

      Rename the given resource
      Overrides:
        `renameTo` in class `URLResource`
      Throws:
        `java.lang.SecurityException`

    - #### list

          public java.lang.String[] list()

      Returns a list of resources contained in the given resource
      Overrides:
        `list` in class `URLResource`

    - #### encode

          public java.lang.String encode(java.lang.String uri)

      Encode according to this resource type. File URIs are encoded.
      Overrides:
        `encode` in class `Resource`
      Parameters:
        `uri` - URI to encode.
      Returns:
        The uri unchanged.

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `URLResource`
      Parameters:
        `o` -
      Returns:
        `true` of the object `o` is a `FileResource` pointing to the same file as this resource.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `URLResource`
      Returns:
        the hashcode.

    - #### copyTo

          public void copyTo(java.io.File destination)
                      throws java.io.IOException

      Overrides:
        `copyTo` in class `Resource`
      Throws:
        `java.io.IOException`

Copyright © 2013 FuseSource, Corp.. All Rights Reserved.