List of utility methods to do File Content Read
String | getFileContents(File testFile) get File Contents byte[] buffer = new byte[(int) testFile.length()]; try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(testFile))) { bis.read(buffer); return new String(buffer); } catch (IOException exception) { throw new RuntimeException(exception); |
String | getFileContents(final File f) get File Contents return getFileContents(f, DEFAULT_ENCODING);
|
String | getFileContents(final File file) Read the contents of the specified file. byte[] buffer; BufferedInputStream inputStream; inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(file)); buffer = new byte[(int) file.length()]; inputStream.read(buffer); } finally { ... |
String | getFileContents(String filename) reads contents of a (text) file and returns them as a string BufferedReader br; if (filename.endsWith(".gz")) br = new BufferedReader( new InputStreamReader(new GZIPInputStream(new FileInputStream(filename)), "UTF-8")); else br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8")); StringBuilder sb = new StringBuilder(); while (true) { ... |
String | getFileContents(String fileName) get File Contents File file = new File(fileName); String results = null; try { int length = (int) file.length(), bytesRead; byte byteArray[] = new byte[length]; ByteArrayOutputStream bytesBuffer = new ByteArrayOutputStream(length); FileInputStream inputStream = new FileInputStream(file); bytesRead = inputStream.read(byteArray); ... |