/** * This method returns an {@code InputStream} which needs to be closed, based on * {@code FileInputStream}. * * @param file * {@code File} to read. * @return an {@code InputStream} materialized by a {@code FileInputStream} * representing the contents of the file @ if an I/O error occurred */ public static InputStream toInputStream(final File file) { if (file == null) { throw new NullPointerException(); } try { return openInputStream(file); } catch (IOException e) { throw new DSSException(e); } }
/** * FROM: Apache * Reads the contents of a file into a byte array. * The file is always closed. * * @param file * the file to read, must not be {@code null} * @return the file contents, never {@code null} */ public static byte[] toByteArray(final File file) { try (InputStream is = openInputStream(file)) { return toByteArray(is); } catch (Exception e) { throw new DSSException(e); } }