X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FIOUtils.java;h=e9a378c0fd6e279c1568afb848808ab83f9cdf5e;hp=0d9bc378a83b856599eae7f2afaec30fa3711332;hb=bb60bd13efae59e804e5d7a5a7590a020835966f;hpb=903453a23ada11bc50ce8f16dfb4f1c0cb920a59 diff --git a/src/be/nikiroo/utils/IOUtils.java b/src/be/nikiroo/utils/IOUtils.java index 0d9bc37..e9a378c 100644 --- a/src/be/nikiroo/utils/IOUtils.java +++ b/src/be/nikiroo/utils/IOUtils.java @@ -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(); + } + } }