File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
src/main/java/org/scijava/util Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 3737import java .io .DataInputStream ;
3838import java .io .File ;
3939import java .io .FileInputStream ;
40+ import java .io .FileOutputStream ;
4041import java .io .FilenameFilter ;
4142import java .io .IOException ;
4243import java .net .JarURLConnection ;
@@ -151,6 +152,24 @@ public static byte[] readFile(final File file) throws IOException {
151152 return bytes ;
152153 }
153154
155+ /**
156+ * Writes the given byte array to the specified file.
157+ *
158+ * @see DigestUtils#bytes(String) To convert a string to a byte array.
159+ * @throws IOException If the file cannot be written.
160+ */
161+ public static void writeFile (final File file , final byte [] bytes )
162+ throws IOException
163+ {
164+ final FileOutputStream out = new FileOutputStream (file );
165+ try {
166+ out .write (bytes );
167+ }
168+ finally {
169+ out .close ();
170+ }
171+ }
172+
154173 /**
155174 * A regular expression to match filenames containing version information.
156175 * <p>
You can’t perform that action at this time.
0 commit comments