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.red5.server.util
Class FileUtil

    java.lang.Object
      org.red5.server.util.FileUtil

    public class FileUtil

extends Object

Generic file utility containing useful file or directory manipulation functions.

Author:
  Paul Gregoire (mondain@gmail.com), Dominick Accattato (daccattato@gmail.com)

Constructor Summary
`FileUtil()`

Method Summary
`static void` | `copy(InputStream in, OutputStream out)`
`static void` | `copyFile(File source, File dest)`
`static void` | `copyFile(String source, String dest)`
`static boolean` | `deleteDirectory(String directory)` Deletes a directory and its contents.
`static boolean` | `deleteDirectory(String directory, boolean useOSNativeDelete)` Deletes a directory and its contents.
`static String` | `formatPath(String absWebappsPath, String contextDirName)` Quick-n-dirty directory formatting to support launching in windows, specifically from ant.
`static String` | `generateCustomName()` Generates a custom name containing numbers and an underscore ex.
`static boolean` | `makeDirectory(String directory)` Create a directory.
`static boolean` | `makeDirectory(String directory, boolean createParents)` Create a directory.
`static void` | `moveFile(String source, String dest)`
`static void` | `rename(String from, String to)` Rename a file natively; using REN on Windows and mv on *nix.
`static void` | `unzip(String compressedFileName, String destinationDir)` Unzips a war file to an application located under the webapps directory

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

Constructor Detail

### FileUtil

    public FileUtil()

Method Detail

### copyFile

    public static void copyFile(File source,
                                File dest)
                         throws IOException

  Throws:
    `IOException`

### copyFile

    public static void copyFile(String source,
                                String dest)
                         throws IOException

  Throws:
    `IOException`

### moveFile

    public static void moveFile(String source,
                                String dest)
                         throws IOException

  Throws:
    `IOException`

### deleteDirectory

    public static boolean deleteDirectory(String directory)
                                   throws IOException

  Deletes a directory and its contents. This will fail if there are any file locks or if the directory cannot be emptied.

  Parameters:
    `directory` - directory to delete
  Returns:
    true if directory was successfully deleted; false if directory did not exist
  Throws:
    `IOException` - if directory cannot be deleted

### deleteDirectory

    public static boolean deleteDirectory(String directory,
                                          boolean useOSNativeDelete)
                                   throws IOException

  Deletes a directory and its contents. This will fail if there are any file locks or if the directory cannot be emptied.

  Parameters:
    `directory` - directory to delete
    `useOSNativeDelete` - flag to signify use of operating system delete function
  Returns:
    true if directory was successfully deleted; false if directory did not exist
  Throws:
    `IOException` - if directory cannot be deleted

### rename

    public static void rename(String from,
                              String to)

  Rename a file natively; using REN on Windows and mv on *nix.

  Parameters:
    `from` - old name
    `to` - new name

### makeDirectory

    public static boolean makeDirectory(String directory)
                                 throws IOException

  Create a directory.

  Parameters:
    `directory` - directory to make
  Returns:
    whether a new directory was made
  Throws:
    `IOException` - if directory does not already exist or cannot be made

### makeDirectory

    public static boolean makeDirectory(String directory,
                                        boolean createParents)
                                 throws IOException

  Create a directory. The parent directories will be created if createParents is passed as true.

  Parameters:
    `directory` - directory
    `createParents` - whether to create all parents
  Returns:
    true if directory was created; false if it already existed
  Throws:
    `IOException` - if we cannot create directory

### unzip

    public static void unzip(String compressedFileName,
                             String destinationDir)

  Unzips a war file to an application located under the webapps directory

  Parameters:
    `compressedFileName` - The String name of the war file
    `destinationDir` - The destination directory, ie: webapps

### copy

    public static void copy(InputStream in,
                            OutputStream out)
                     throws IOException

  Throws:
    `IOException`

### formatPath

    public static String formatPath(String absWebappsPath,
                                    String contextDirName)

  Quick-n-dirty directory formatting to support launching in windows, specifically from ant.

  Parameters:
    `absWebappsPath` - abs webapps path
    `contextDirName` - conext directory name
  Returns:
    full path

### generateCustomName

    public static String generateCustomName()

  Generates a custom name containing numbers and an underscore ex. 282818_00023. The name contains current seconds and a random number component.

  Returns:
    custom name

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 © 2006-2010 The Red5 Project