public class IOUtil extends Object
| Constructor and Description |
|---|
IOUtil() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public static String getFileContentAsString(File file) throws IOException, IllegalArgumentException
UTF-8 charset.file - the fileIOException - any io exceptionIllegalArgumentException - if any argument is nullpublic static String getFileContentAsString(File file, String charset) throws IOException, IllegalArgumentException
file - the filecharset - the charsetIOException - any io exceptionIllegalArgumentException - if any argument is nullpublic static String getFileContentAsString(String fileName, String charset) throws IOException, IllegalArgumentException
fileName - the file namecharset - the charsetIOException - any io exceptionIllegalArgumentException - if any argument is nullpublic static String getFileContentAsString(String fileName) throws IOException, IllegalArgumentException
UTF-8 charset.fileName - the file nameIOException - any io exceptionIllegalArgumentException - if any argument is nullpublic static String getStreamContentAsString(InputStream is) throws IOException, IllegalArgumentException
UTF-8 charset.is - the streamIOException - any io exceptionIllegalArgumentException - if the specified stream is nullpublic static byte[] getFileContentAsBytes(String fileName) throws IOException, IllegalArgumentException
fileName - the file nameIOException - any io exceptionIllegalArgumentException - if the specified file name is nullpublic static byte[] getStreamContentAsBytes(InputStream is) throws IOException, IllegalArgumentException
is - the input streamIOException - if any IOException occurs during a readIllegalArgumentException - if the provided input stream is nullpublic static String getResourceAsString(String resource) throws IOException
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.resource - the resource nameIllegalArgumentException - if the specified argument is null or the loaded resource does not existIOException - thrown by accessing the resourcepublic static byte[] getResourceAsBytes(String resource) throws IOException
ClassLoader.getResource(String) on the context classloader
associated with the current thread of execution.resource - the resource nameIllegalArgumentException - if the specified argument is null or the loaded resource does not existIOException - thrown by accessing the resource@Deprecated public static byte[] serialize(Object obj) throws Exception
Exception@Deprecated public static Object deserialize(byte[] bytes) throws Exception
Exception@Deprecated public static String getFileContenntAsString(File file) throws Exception
getFileContentAsString(File) instead.Exception@Deprecated public static String getFileContenntAsString(File file, String encoding) throws Exception
getFileContentAsString(File,String) instead.Exception@Deprecated public static String getFileContenntAsString(String fileName, String encoding) throws Exception
getFileContentAsString(String,String) instead.Exception@Deprecated public static String getFileContenntAsString(String fileName) throws Exception
getFileContentAsString(String) instead.ExceptionCopyright © 2018 eXo Platform SAS. All Rights Reserved.