com.atlassian.user.util
Class FileUtils

java.lang.Object
  extended by com.atlassian.user.util.FileUtils

public class FileUtils
extends Object


Constructor Summary
FileUtils()
           
 
Method Summary
static int copy(InputStream input, OutputStream output)
          Copy bytes from an InputStream to an OutputStream.
static int copy(InputStream input, OutputStream output, int bufferSize)
          Copy bytes from an InputStream to an OutputStream.
static void copyFile(File source, File destination)
          Copy file from source to destination.
static File copyIntoTemporaryFile(String source, 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(File dir)
          safely performs a recursive delete on a directory
static void deleteFilesBeginningWith(String directory, String prefix)
           
static String getInputStreamTextContent(InputStream is)
           
static void shutdownStream(InputStream input)
          Unconditionally close an InputStream.
static void shutdownStream(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(File source,
                            File destination)
                     throws 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:
IOException - if source does not exist, destination cannot be written to, or an IO error occurs during copying.

copy

public static int copy(InputStream input,
                       OutputStream output)
                throws 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:
IOException - In case of an I/O problem

copy

public static int copy(InputStream input,
                       OutputStream output,
                       int bufferSize)
                throws 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:
IOException - In case of an I/O problem

shutdownStream

public static void shutdownStream(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(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(File dir)
safely performs a recursive delete on a directory

Parameters:
dir -
Returns:

deleteFilesBeginningWith

public static void deleteFilesBeginningWith(String directory,
                                            String prefix)

copyIntoTemporaryFile

public static File copyIntoTemporaryFile(String source,
                                         String fileName)
                                  throws IOException,
                                         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:
IOException
Exception

getInputStreamTextContent

public static String getInputStreamTextContent(InputStream is)


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