au.gov.nehta.vendorlibrary.pcehr.clients.common.util
Class FileUtils

java.lang.Object
  extended by au.gov.nehta.vendorlibrary.pcehr.clients.common.util.FileUtils

public final class FileUtils
extends java.lang.Object

File handling utilities.


Method Summary
static java.util.Map<java.lang.String,byte[]> extractZipEntries(byte[] packageContent)
          Read ZIP entries and file content into memory.
static byte[] getCdaDocument(byte[] packageContent)
          Retrieve root CDA document file content from a CDA package.
static byte[] loadFile(java.io.File file)
          Load the contents of a file.
static
<T> T
loadXml(java.io.File file, java.lang.Class<? extends T> clazz)
          Load an XML file into a Java object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadFile

public static byte[] loadFile(java.io.File file)
                       throws java.io.IOException
Load the contents of a file.

Parameters:
file - File object to load.
Returns:
The contents of the file.
Throws:
java.io.IOException - thrown in the event the file cannot be read in to memory.

loadXml

public static <T> T loadXml(java.io.File file,
                            java.lang.Class<? extends T> clazz)
                 throws javax.xml.bind.JAXBException
Load an XML file into a Java object.

Parameters:
file - File object to load.
clazz - class to attempt to marshal to.
Returns:
The Java object unmarshalled from the contents of the XML file.
Throws:
javax.xml.bind.JAXBException - thrown in the event the file contents cannot be unmarshalled.

getCdaDocument

public static byte[] getCdaDocument(byte[] packageContent)
Retrieve root CDA document file content from a CDA package.

Parameters:
packageContent - byte array representation of the CDA package.
Returns:
byte[].

extractZipEntries

public static java.util.Map<java.lang.String,byte[]> extractZipEntries(byte[] packageContent)
                                                                throws java.io.IOException
Read ZIP entries and file content into memory.

Parameters:
packageContent - byte array containing package content.
Returns:
Map containing list of matching file names and file content byte arrays, or null.
Throws:
java.io.IOException - Thrown if ZIP I/O operations fail.