eXo Kernel :: Commons Utils 2.4.10-UXP01

org.exoplatform.commons.utils
Class IOUtil

java.lang.Object
  extended by org.exoplatform.commons.utils.IOUtil

public class IOUtil
extends Object


Constructor Summary
IOUtil()
           
 
Method Summary
static Object deserialize(byte[] bytes)
          Deprecated. 
static String getFileContenntAsString(File file)
          Deprecated. 
static String getFileContenntAsString(File file, String encoding)
          Deprecated. 
static String getFileContenntAsString(String fileName)
          Deprecated. 
static String getFileContenntAsString(String fileName, String encoding)
          Deprecated. 
static byte[] getFileContentAsBytes(String fileName)
          Returns the content of the file specified by its name as a byte array.
static String getFileContentAsString(File file)
          Returns the content of the specified file as a string using the UTF-8 charset.
static String getFileContentAsString(File file, String charset)
          Returns the content of the specified file as a string using the specified charset.
static String getFileContentAsString(String fileName)
          Returns the content of the specified file as a string using the UTF-8 charset.
static String getFileContentAsString(String fileName, String charset)
          Returns the content of the specified file as a string using the specified charset.
static byte[] getResourceAsBytes(String resource)
          Get a resource from the thread context classloader and returns its content as a byte array.
static String getResourceAsString(String resource)
          Get a resource from the thread context classloader and returns its content as a string.
static byte[] getStreamContentAsBytes(InputStream is)
          Reads a stream until its end and returns its content as a byte array.
static String getStreamContentAsString(InputStream is)
          Returns the content of the specified stream as a string using the UTF-8 charset.
static byte[] serialize(Object obj)
          Deprecated. 
 
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

getFileContentAsString

public static String getFileContentAsString(File file)
                                     throws IOException,
                                            IllegalArgumentException
Returns the content of the specified file as a string using the UTF-8 charset.

Parameters:
file - the file
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if any argument is null

getFileContentAsString

public static String getFileContentAsString(File file,
                                            String charset)
                                     throws IOException,
                                            IllegalArgumentException
Returns the content of the specified file as a string using the specified charset.

Parameters:
file - the file
charset - the charset
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if any argument is null

getFileContentAsString

public static String getFileContentAsString(String fileName,
                                            String charset)
                                     throws IOException,
                                            IllegalArgumentException
Returns the content of the specified file as a string using the specified charset.

Parameters:
fileName - the file name
charset - the charset
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if any argument is null

getFileContentAsString

public static String getFileContentAsString(String fileName)
                                     throws IOException,
                                            IllegalArgumentException
Returns the content of the specified file as a string using the UTF-8 charset.

Parameters:
fileName - the file name
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if any argument is null

getStreamContentAsString

public static String getStreamContentAsString(InputStream is)
                                       throws IOException,
                                              IllegalArgumentException
Returns the content of the specified stream as a string using the UTF-8 charset.

Parameters:
is - the stream
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if the specified stream is null

getFileContentAsBytes

public static byte[] getFileContentAsBytes(String fileName)
                                    throws IOException,
                                           IllegalArgumentException
Returns the content of the file specified by its name as a byte array.

Parameters:
fileName - the file name
Returns:
the content
Throws:
IOException - any io exception
IllegalArgumentException - if the specified file name is null

getStreamContentAsBytes

public static byte[] getStreamContentAsBytes(InputStream is)
                                      throws IOException,
                                             IllegalArgumentException
Reads a stream until its end and returns its content as a byte array. The provided stream will be closed by this method. Any runtime exception thrown when the stream is closed will be ignored and not rethrown.

Parameters:
is - the input stream
Returns:
the data read from the input stream its end
Throws:
IOException - if any IOException occurs during a read
IllegalArgumentException - if the provided input stream is null

getResourceAsString

public static String getResourceAsString(String resource)
                                  throws IOException
Get a resource from the thread context classloader and returns its content as a string. The resource is obtained by calling the method ClassLoader.getResource(String) on the context classloader associated with the current thread of execution. The charset used for encoding the resource as a string is UTF-8.

Parameters:
resource - the resource name
Returns:
the resource content
Throws:
IllegalArgumentException - if the specified argument is null or the loaded resource does not exist
IOException - thrown by accessing the resource

getResourceAsBytes

public static byte[] getResourceAsBytes(String resource)
                                 throws IOException
Get a resource from the thread context classloader and returns its content as a byte array. The resource is obtained by calling the method ClassLoader.getResource(String) on the context classloader associated with the current thread of execution.

Parameters:
resource - the resource name
Returns:
the resource content
Throws:
IllegalArgumentException - if the specified argument is null or the loaded resource does not exist
IOException - thrown by accessing the resource

serialize

@Deprecated
public static byte[] serialize(Object obj)
                        throws Exception
Deprecated. 

Throws:
Exception

deserialize

@Deprecated
public static Object deserialize(byte[] bytes)
                          throws Exception
Deprecated. 

Throws:
Exception

getFileContenntAsString

@Deprecated
public static String getFileContenntAsString(File file)
                                      throws Exception
Deprecated. 

Use getFileContentAsString(File) instead.

Throws:
Exception

getFileContenntAsString

@Deprecated
public static String getFileContenntAsString(File file,
                                                        String encoding)
                                      throws Exception
Deprecated. 

Use getFileContentAsString(File,String) instead.

Throws:
Exception

getFileContenntAsString

@Deprecated
public static String getFileContenntAsString(String fileName,
                                                        String encoding)
                                      throws Exception
Deprecated. 

Use getFileContentAsString(String,String) instead.

Throws:
Exception

getFileContenntAsString

@Deprecated
public static String getFileContenntAsString(String fileName)
                                      throws Exception
Deprecated. 

Use getFileContentAsString(String) instead.

Throws:
Exception

eXo Kernel :: Commons Utils 2.4.10-UXP01

Copyright © 2014 eXo Platform SAS. All Rights Reserved.