org.apache.airavata.common.utils
Class IOUtil

java.lang.Object
  extended by org.apache.airavata.common.utils.IOUtil

public class IOUtil
extends Object


Constructor Summary
IOUtil()
           
 
Method Summary
static boolean deleteDirectory(File path)
           
static String getExtension(File file)
          Gets the extension of a specified file.
static String readFileToString(File file)
          Returns the content of a specified file as a String.
static String readFileToString(String path)
          Returns the content of a specified file as a String.
static byte[] readToByteArray(File file)
           
static byte[] readToByteArray(InputStream inputStream)
           
static String readToString(InputStream stream)
          Returns a String read from a specified InputStream.
static String readToString(Reader reader)
          Returns a String read from a specified Reader.
static void writeToFile(InputStream inputStream, File file)
           
static void writeToFile(String content, File file)
           
static void writeToFile(String content, String path)
           
static void writeToWriter(String content, Writer writer)
          Writes a specified String to a specified Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IOUtil

public IOUtil()
Method Detail

writeToFile

public static void writeToFile(String content,
                               String path)
                        throws IOException
Parameters:
path -
content -
Throws:
IOException

writeToFile

public static void writeToFile(String content,
                               File file)
                        throws IOException
Parameters:
content -
file -
Throws:
IOException

writeToFile

public static void writeToFile(InputStream inputStream,
                               File file)
                        throws IOException
Parameters:
inputStream -
file -
Throws:
IOException

writeToWriter

public static void writeToWriter(String content,
                                 Writer writer)
                          throws IOException
Writes a specified String to a specified Writer.

Parameters:
content - The content to write
writer - The specified Writer
Throws:
IOException

readFileToString

public static String readFileToString(String path)
                               throws IOException
Returns the content of a specified file as a String.

Parameters:
path -
Returns:
the content of a specified file as a String
Throws:
IOException

readFileToString

public static String readFileToString(File file)
                               throws IOException
Returns the content of a specified file as a String.

Parameters:
file -
Returns:
the content of a specified file as a String
Throws:
IOException

readToString

public static String readToString(InputStream stream)
                           throws IOException
Returns a String read from a specified InputStream.

Parameters:
stream - The specified InputStream
Returns:
The String read from the specified InputStream
Throws:
IOException

readToString

public static String readToString(Reader reader)
                           throws IOException
Returns a String read from a specified Reader.

Parameters:
reader - The specified Reader
Returns:
The String read from the specified Reader
Throws:
IOException

readToByteArray

public static byte[] readToByteArray(File file)
                              throws IOException
Parameters:
file -
Returns:
The byte array
Throws:
IOException

readToByteArray

public static byte[] readToByteArray(InputStream inputStream)
                              throws IOException
Parameters:
inputStream -
Returns:
The byte array.
Throws:
IOException

deleteDirectory

public static boolean deleteDirectory(File path)
Parameters:
path -
Returns:
true if and only if the file or directory is successfully deleted; false otherwise

getExtension

public static String getExtension(File file)
Gets the extension of a specified file.

Parameters:
file - the specified file.
Returns:
the extension of the file in lower case if there is an extension; null otherwise


Copyright © 2011-2012 The Apache Software Foundation. All Rights Reserved.