Version 4.4.5
[nikiroo-utils.git] / src / be / nikiroo / utils / IOUtils.java
index 0d9bc378a83b856599eae7f2afaec30fa3711332..e9a378c0fd6e279c1568afb848808ab83f9cdf5e 100644 (file)
@@ -17,7 +17,7 @@ import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
 /**
- * This class offer some utilities based around Streams.
+ * This class offer some utilities based around Streams and Files.
  * 
  * @author niki
  */
@@ -448,4 +448,24 @@ public class IOUtils {
 
                return array;
        }
+
+       /**
+        * Convert the {@link File} into a byte array.
+        * 
+        * @param file
+        *            the input {@link File}
+        * 
+        * @return the array
+        * 
+        * @throws IOException
+        *             in case of I/O error
+        */
+       public static byte[] toByteArray(File file) throws IOException {
+               FileInputStream fis = new FileInputStream(file);
+               try {
+                       return toByteArray(fis);
+               } finally {
+                       fis.close();
+               }
+       }
 }