List of utility methods to do File Read
String | readTemplate(String filePath) read Template File f = new File(filePath); if (!f.canRead()) throw new IOException(); BufferedReader in = new BufferedReader(new FileReader(filePath)); String template = ""; String line; while ((line = in.readLine()) != null) { template += line; ... |
String | readTextFile(File file) read Text File String text = null; InputStream is = null; if (null != file) { try { is = new FileInputStream(file); text = readTextInputStream(is); ; } finally { ... |
char[] | loadFile(String str) load file into char arrray char c[] = null; BufferedReader reader = null; try { File f = new File(str); reader = new BufferedReader(new InputStreamReader( new FileInputStream(f))); int len = (int) f.length(); c = new char[len]; ... |
String | getFileContent(File file) get File Content FileInputStream fin = null; byte fileContent[] = null; try { fin = new FileInputStream(file); fileContent = new byte[(int) file.length()]; fin.read(fileContent); } catch (FileNotFoundException e) { } catch (IOException ioe) { ... |
String | LoadFile(String fileName, Resources resources) Load File InputStream iS; iS = resources.getAssets().open(fileName); byte[] buffer = new byte[iS.available()]; iS.read(buffer); ByteArrayOutputStream oS = new ByteArrayOutputStream(); oS.write(buffer); oS.close(); iS.close(); ... |
byte[] | readFileToByteArray(String pathToFile) read File To Byte Array byte[] result = null; try { File file = new File(pathToFile); if (file.length() <= Integer.MAX_VALUE) { result = new byte[(int) file.length()]; @SuppressWarnings("resource") RandomAccessFile raf = new RandomAccessFile(file, "r"); raf.readFully(result); ... |