List of utility methods to do FileInputStream Read
byte[] | readFile(File file) read File FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; int read; while ((read = fis.read(buf)) != -1) { baos.write(buf, 0, read); fis.close(); ... |
String | readFile(File file) read File String text = ""; FileInputStream fileIS = null; DataInputStream dataIS = null; try { fileIS = new FileInputStream(file); dataIS = new DataInputStream(fileIS); int length = dataIS.available(); byte[] buffer = new byte[length]; ... |
byte[] | readFile(File file) read a file and return file context as a byte[] InputStream inStream = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int n; byte[] buf = new byte[4096]; do { n = inStream.read(buf); if (n >= 0) bos.write(buf, 0, n); ... |
byte[] | readFile(File file) read File FileInputStream fis = new FileInputStream(file); byte[] buff = new byte[(int) file.length()]; fis.read(buff); fis.close(); return buff; |
String | readFile(File file) read File FileInputStream fis = new FileInputStream(file); byte[] buffer = new byte[fis.available()]; while (fis.available() != 0) { fis.read(buffer); fis.close(); return new String(buffer); |
String | readFile(File file) read File try (FileInputStream in = new FileInputStream(file)) { byte[] bytes = readFully(in); return new String(bytes, "UTF-8"); |
byte[] | readFile(File file) read File int length = (int) file.length(); FileInputStream fis = new FileInputStream(file); byte[] result = new byte[length]; int pos = 0; while (pos < length) { pos += fis.read(result, pos, length - pos); fis.close(); ... |
String | readFile(File file) Read the contents of a file as a single string. InputStream is = new FileInputStream(file); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[4096]; int read; while ((read = is.read(buf)) != -1) { baos.write(buf, 0, read); is.close(); ... |
byte[] | readFile(File file) Reads a file in binary format byte[] b = new byte[(int) file.length()]; try { FileInputStream fs = new FileInputStream(file); fs.read(b); fs.close(); } catch (FileNotFoundException e) { System.out.println("File Not Found."); e.printStackTrace(); ... |
byte[] | readFile(File file) read File try { if (file.length() > 1 << 30) { throw new ArrayIndexOutOfBoundsException("File is too big"); byte[] data = new byte[(int) file.length()]; FileInputStream fis = new FileInputStream(file); try { int n = 0; ... |