com.metamatrix.core.util
Class ObjectConverterUtil

java.lang.Object
  extended by com.metamatrix.core.util.ObjectConverterUtil

public class ObjectConverterUtil
extends java.lang.Object


Constructor Summary
ObjectConverterUtil()
           
 
Method Summary
static char[] bytesToChar(byte[] bytes, java.lang.String encoding)
          Returns the given bytes as a char array using a given encoding (null means platform default).
static byte[] convertFileToByteArray(java.io.File file)
          Returns the contents of the given file as a byte array.
static char[] convertFileToCharArray(java.io.File file, java.lang.String encoding)
          Returns the contents of the given file as a char array.
static java.lang.String convertFileToString(java.io.File file)
          Returns the contents of the given file as a string.
protected static byte[] convertToByteArray(java.sql.Blob data)
           
static byte[] convertToByteArray(java.io.InputStream is)
           
static byte[] convertToByteArray(java.io.InputStream stream, int length)
          Returns the given input stream's contents as a byte array.
static byte[] convertToByteArray(java.lang.Object data)
           
static byte[] convertToByteArray(java.util.zip.ZipEntry ze, java.util.zip.ZipFile zip)
          Returns the contents of the given zip entry as a byte array.
static char[] convertToCharArray(java.io.InputStream stream, int length, java.lang.String encoding)
          Returns the given input stream's contents as a character array.
static java.io.InputStream convertToInputStream(byte[] data)
           
static java.io.InputStream convertToInputStream(char[] data)
           
static java.io.InputStream convertToInputStream(java.io.File file)
           
static java.io.InputStream convertToInputStream(java.lang.String data)
           
static java.lang.String convertToString(java.io.InputStream stream)
          Returns the contents of the given InputStream as a string.
static void write(byte[] data, java.lang.String fileName)
           
static void write(char[] data, java.lang.String fileName)
           
static void write(java.io.InputStream is, java.lang.String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectConverterUtil

public ObjectConverterUtil()
Method Detail

convertToByteArray

protected static byte[] convertToByteArray(java.sql.Blob data)
                                    throws MetaMatrixCoreException
Throws:
MetaMatrixCoreException

convertToByteArray

public static byte[] convertToByteArray(java.lang.Object data)
                                 throws MetaMatrixCoreException,
                                        java.io.IOException
Throws:
MetaMatrixCoreException
java.io.IOException

convertToByteArray

public static byte[] convertToByteArray(java.io.InputStream is)
                                 throws java.io.IOException
Throws:
java.io.IOException

convertToInputStream

public static java.io.InputStream convertToInputStream(byte[] data)

convertToInputStream

public static java.io.InputStream convertToInputStream(java.lang.String data)

convertToInputStream

public static java.io.InputStream convertToInputStream(char[] data)

write

public static void write(java.io.InputStream is,
                         java.lang.String fileName)
                  throws java.lang.Exception
Throws:
java.lang.Exception

write

public static void write(byte[] data,
                         java.lang.String fileName)
                  throws java.lang.Exception
Throws:
java.lang.Exception

write

public static void write(char[] data,
                         java.lang.String fileName)
                  throws java.lang.Exception
Throws:
java.lang.Exception

convertToInputStream

public static java.io.InputStream convertToInputStream(java.io.File file)

bytesToChar

public static char[] bytesToChar(byte[] bytes,
                                 java.lang.String encoding)
                          throws java.io.IOException
Returns the given bytes as a char array using a given encoding (null means platform default).

Throws:
java.io.IOException

convertFileToByteArray

public static byte[] convertFileToByteArray(java.io.File file)
                                     throws java.io.IOException
Returns the contents of the given file as a byte array.

Throws:
java.io.IOException - if a problem occured reading the file.

convertFileToCharArray

public static char[] convertFileToCharArray(java.io.File file,
                                            java.lang.String encoding)
                                     throws java.io.IOException
Returns the contents of the given file as a char array. When encoding is null, then the platform default one is used

Throws:
java.io.IOException - if a problem occured reading the file.

convertFileToString

public static java.lang.String convertFileToString(java.io.File file)
                                            throws java.io.IOException
Returns the contents of the given file as a string.

Throws:
java.io.IOException - if a problem occured reading the file.

convertToString

public static java.lang.String convertToString(java.io.InputStream stream)
                                        throws java.io.IOException
Returns the contents of the given InputStream as a string.

Throws:
java.io.IOException - if a problem occured reading the file.

convertToByteArray

public static byte[] convertToByteArray(java.io.InputStream stream,
                                        int length)
                                 throws java.io.IOException
Returns the given input stream's contents as a byte array. If a length is specified (ie. if length != -1), only length bytes are returned. Otherwise all bytes in the stream are returned. Note this doesn't close the stream.

Throws:
java.io.IOException - if a problem occured reading the stream.

convertToCharArray

public static char[] convertToCharArray(java.io.InputStream stream,
                                        int length,
                                        java.lang.String encoding)
                                 throws java.io.IOException
Returns the given input stream's contents as a character array. If a length is specified (ie. if length != -1), only length chars are returned. Otherwise all chars in the stream are returned. Note this doesn't close the stream.

Throws:
java.io.IOException - if a problem occured reading the stream.

convertToByteArray

public static byte[] convertToByteArray(java.util.zip.ZipEntry ze,
                                        java.util.zip.ZipFile zip)
                                 throws java.io.IOException
Returns the contents of the given zip entry as a byte array.

Throws:
java.io.IOException - if a problem occured reading the zip entry.


Copyright © 2009. All Rights Reserved.