List of utility methods to do FileInputStream Read
byte[] | readFile(File file) Returns file's contents in a byte array.. byte[] cont = null; FileInputStream fi = new FileInputStream(file); try { long len = file.length(); cont = new byte[(int) len]; fi.read(cont); } finally { fi.close(); ... |
byte[] | readFile(File file) read File if (!file.exists() || file.isDirectory()) return null; try { FileInputStream fileinputstream = new FileInputStream(file); byte abyte0[] = new byte[fileinputstream.available()]; fileinputstream.read(abyte0); fileinputstream.close(); return abyte0; ... |
byte[] | readFile(File file) read File return readStream(new FileInputStream(file)); |
byte[] | readFile(File file) read File byte[] bytes = null; InputStream inStream = null; long length = file.length(); try { inStream = new FileInputStream(file); if (length > Integer.MAX_VALUE) { throw new IOException("File too long " + file.getName()); bytes = new byte[(int) length]; int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = inStream.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); } finally { if (inStream != null) { inStream.close(); return bytes; |
byte[] | readFile(File file) read File FileInputStream fis = null; try { fis = new FileInputStream(file); int length = (int) file.length(); ByteArrayOutputStream baos = new ByteArrayOutputStream(length); byte[] buffer = new byte[4096]; int i = 0; while (i < length) { ... |
byte[] | readFile(File file) read File if (file.length() > 10000000) { throw new IOException("File too big: " + file.getAbsolutePath() + ", size: " + file.length()); byte[] data = new byte[(int) file.length()]; InputStream in = new FileInputStream(file); try { in.read(data); } finally { ... |
byte[] | readFile(File file) read File FileInputStream fis = new FileInputStream(file); byte[] buf = new byte[2048]; int read; ByteArrayOutputStream bos = new ByteArrayOutputStream(); while ((read = fis.read(buf)) != -1) { bos.write(buf, 0, read); fis.close(); ... |
String | readFile(File file) read File try { FileInputStream fis = new FileInputStream(file); byte[] data = new byte[(int) file.length()]; fis.read(data); fis.close(); String str = new String(data, "UTF-8"); return str; } catch (IOException e) { ... |
byte[] | readFile(File file) Reads a file, and returns all bytes from that file. BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); byte[] d = new byte[in.available()]; in.read(d); return d; } catch (Exception exception) { exception.printStackTrace(); ... |
byte[] | readFile(File file) Read the given file, returning a byte[] of its contents.
if (file == null) { throw new NullPointerException("file == null"); long length = file.length(); int len = (int) length; if (length != len) { throw new RuntimeException("File too long: " + file); byte[] buf = new byte[len]; FileInputStream fis = new FileInputStream(file); int at = 0; while (at < len) { int amt = fis.read(buf, at, len - at); if (amt == -1) { throw new RuntimeException("Unexpected EOF at " + at + " in file: " + file); at += amt; return buf; |