Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.owasp.dependencycheck.utils
Class FileUtils

    java.lang.Object
      org.owasp.dependencycheck.utils.FileUtils

    public final class FileUtils

extends Object

A collection of utilities for processing information about files.

Author:
  Jeremy Long (jeremy.long@owasp.org)

Method Summary
`static void` | `delete(File file)` Deletes a file.
`static void` | `extractFiles(File archive, File extractTo)` Extracts the contents of an archive into the specified directory.
`static void` | `extractFiles(File archive, File extractTo, Engine engine)` Extracts the contents of an archive into the specified directory.
`static File` | `getDataDirectory(String configuredFilePath, Class clazz)` Deprecated. This method should no longer be used. See the implementation in dependency-check-cli/App.java to see how the data directory should be set.
`static String` | `getFileExtension(String fileName)` Returns the (lowercase) file extension for a specified file.
`static File` | `getPathToJar(Class clazz)` Deprecated. this should no longer be used.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### getFileExtension

    public static String getFileExtension(String fileName)

  Returns the (lowercase) file extension for a specified file.

  Parameters:
    `fileName` - the file name to retrieve the file extension from.
  Returns:
    the file extension.

### delete

    public static void delete(File file)
                       throws IOException

  Deletes a file. If the File is a directory it will recursively delete the contents.

  Parameters:
    `file` - the File to delete
  Throws:
    `IOException` - is thrown if the file could not be deleted

### getDataDirectory

    @Deprecated
    public static File getDataDirectory(String configuredFilePath,
                                                   Class clazz)
                                 throws IOException

  Deprecated. This method should no longer be used. See the implementation in dependency-check-cli/App.java to see how the data directory should be set.

  Returns the data directory. If a path was specified in dependencycheck.properties or was specified using the Settings object, and the path exists, that path will be returned as a File object. If it does not exist, then a File object will be created based on the file location of the JAR containing the specified class.

  Parameters:
    `configuredFilePath` - the configured relative or absolute path
    `clazz` - the class whos path will be resolved
  Returns:
    a File object
  Throws:
    `IOException` - is thrown if the path could not be decoded

### getPathToJar

    @Deprecated
    public static File getPathToJar(Class clazz)
                             throws UnsupportedEncodingException

  Deprecated. this should no longer be used.

  Retrieves the physical path to the parent directory containing the provided class. For example, if a JAR file contained a class org.something.clazz this method would return the parent directory of the JAR file.

  Parameters:
    `clazz` - the class to determine the parent directory of
  Returns:
    the parent directory of the file containing the specified class.
  Throws:
    `UnsupportedEncodingException` - thrown if UTF-8 is not supported.

### extractFiles

    public static void extractFiles(File archive,
                                    File extractTo)
                             throws ExtractionException

  Extracts the contents of an archive into the specified directory.

  Parameters:
    `archive` - an archive file such as a WAR or EAR
    `extractTo` - a directory to extract the contents to
  Throws:
    `ExtractionException` - thrown if an exception occurs while extracting the files

### extractFiles

    public static void extractFiles(File archive,
                                    File extractTo,
                                    Engine engine)
                             throws ExtractionException

  Extracts the contents of an archive into the specified directory. The files are only extracted if they are supported by the analyzers loaded into the specified engine. If the engine is specified as null then all files are extracted.

  Parameters:
    `archive` - an archive file such as a WAR or EAR
    `extractTo` - a directory to extract the contents to
    `engine` - the scanning engine
  Throws:
    `ExtractionException` - thrown if there is an error extracting the files

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012-2013 OWASP. All Rights Reserved.