/**
* Reads the content of a file into an array of bytes
*/
- public static byte[] readFileIntoByteArray(String fileName) throws IOException {
- InputStream input = new FileInputStream(fileName);
+ public static byte[] readFileIntoByteArray(File aFile) throws IOException {
+ InputStream input = new FileInputStream(aFile);
ByteArrayOutputStream result = new ByteArrayOutputStream();
IORoutines.copyStream(input, result);
return result.toByteArray();
}
+ /**
+ * Reads the content of a file into an array of bytes
+ */
+ public static void writeByteArrayIntoFile(byte[] anArray, File aFile) throws IOException {
+ OutputStream output = new FileOutputStream(aFile);
+
+ try {
+ ByteArrayInputStream input = new ByteArrayInputStream(anArray);
+ try {
+ IORoutines.copyStream(input, output);
+ }
+ finally {
+ input.close();
+ }
+ }
+ finally {
+ output.close();
+ }
+ }
+
+
+
/**
* Creates all parent directories of a file if they do not exist
*/