/** * Reads a text file as a string. * * @param filename The name of the file. * * @return The contents of the file. */ public static byte[] readFileAsBytes(String filename) { try(BufferedInputStream is = new BufferedInputStream(new FileInputStream(filename))) { return readStreamAsString(is); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Reads a text file as a string. * * @param file The file. * * @return The contents of the file. */ public static String readFileAsString(File file) { try(BufferedInputStream is = new BufferedInputStream(new FileInputStream(file))) { return new String(readStreamAsString(is)); } catch (IOException e) { throw new RuntimeException(e); } }