com.atlassian.user.util
Class FileUtils

java.lang.Object
  extended bycom.atlassian.user.util.FileUtils

public class FileUtils
extends java.lang.Object


Constructor Summary
FileUtils()
           
 
Method Summary
static int copy(java.io.InputStream input, java.io.OutputStream output)
          Copy bytes from an InputStream to an OutputStream.
static int copy(java.io.InputStream input, java.io.OutputStream output, int bufferSize)
          Copy bytes from an InputStream to an OutputStream.
static void copyFile(java.io.File source, java.io.File destination)
          Copy file from source to destination.
static java.io.File copyIntoTemporaryFile(java.lang.String source, java.lang.String fileName)
          creates a temp file with a given filename from an input stream in the classpath or a file in the filesystem
static boolean deleteDir(java.io.File dir)
          safely performs a recursive delete on a directory
static void deleteFilesBeginningWith(java.lang.String directory, java.lang.String prefix)
           
static java.lang.String getInputStreamTextContent(java.io.InputStream is)
           
static void shutdownStream(java.io.InputStream input)
          Unconditionally close an InputStream.
static void shutdownStream(java.io.OutputStream output)
          Unconditionally close an OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

copyFile

public static void copyFile(java.io.File source,
                            java.io.File destination)
                     throws java.io.IOException
Copy file from source to destination. The directories up to destination will be created if they don't already exist. destination will be overwritten if it already exists.

Parameters:
source - An existing non-directory File to copy bytes from.
destination - A non-directory File to write bytes to (possibly overwriting).
Throws:
java.io.IOException - if source does not exist, destination cannot be written to, or an IO error occurs during copying.

copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output)
                throws java.io.IOException
Copy bytes from an InputStream to an OutputStream.

Parameters:
input - the InputStream to read from
output - the OutputStream to write to
Returns:
the number of bytes copied
Throws:
java.io.IOException - In case of an I/O problem

copy

public static int copy(java.io.InputStream input,
                       java.io.OutputStream output,
                       int bufferSize)
                throws java.io.IOException
Copy bytes from an InputStream to an OutputStream.

Parameters:
input - the InputStream to read from
output - the OutputStream to write to
bufferSize - Size of internal buffer to use.
Returns:
the number of bytes copied
Throws:
java.io.IOException - In case of an I/O problem

shutdownStream

public static void shutdownStream(java.io.OutputStream output)
Unconditionally close an OutputStream. Equivalent to OutputStream.close(), except any exceptions will be ignored.

Parameters:
output - A (possibly null) OutputStream

shutdownStream

public static void shutdownStream(java.io.InputStream input)
Unconditionally close an InputStream. Equivalent to InputStream.close(), except any exceptions will be ignored.

Parameters:
input - A (possibly null) InputStream

deleteDir

public static boolean deleteDir(java.io.File dir)
safely performs a recursive delete on a directory

Parameters:
dir -
Returns:

deleteFilesBeginningWith

public static void deleteFilesBeginningWith(java.lang.String directory,
                                            java.lang.String prefix)

copyIntoTemporaryFile

public static java.io.File copyIntoTemporaryFile(java.lang.String source,
                                                 java.lang.String fileName)
                                          throws java.io.IOException,
                                                 java.lang.Exception
creates a temp file with a given filename from an input stream in the classpath or a file in the filesystem

Parameters:
fileName -
Returns:
Throws:
java.io.IOException
java.lang.Exception

getInputStreamTextContent

public static java.lang.String getInputStreamTextContent(java.io.InputStream is)


Copyright © 2005-2008 Atlassian Software Systems Pty Ltd. All Rights Reserved.