List of utility methods to do Text File Read
List | fileToListByLine(String fileName) file To List By Line List<String> lineList = new LinkedList<String>(); String line = ""; BufferedReader in = null; try { in = new BufferedReader(new FileReader(fileName)); while ((line = in.readLine()) != null) { lineList.add(line); } catch (Exception e) { throw e; } finally { if (null != in) { in.close(); return lineList; |
boolean | fileToSet(final String dirname, final String filename, final Set file To Set return fileToSet(dirname, filename, set, logger);
|
String | getFileContent(File file) get File Content Writer swriter = null; Reader reader = null; try { reader = new FileReader(file); swriter = new StringWriter(); int len = 0; char[] buffer = new char[1024]; while ((len = reader.read(buffer)) > 0) { ... |
String | getFileContent(File file, String charSet) get File Content ByteArrayOutputStream swriter = null; OutputStream temp = null; InputStream reader = null; try { reader = new FileInputStream(file); swriter = new ByteArrayOutputStream(); temp = new BufferedOutputStream(swriter); int len = 0; ... |
String | getFileResourceText(String path) Gets the text from the URL resource. BufferedReader fileReader = null; StringBuilder stringBuilder = new StringBuilder(); try { fileReader = new BufferedReader(new FileReader(path)); String line = null; while ((line = fileReader.readLine()) != null) { stringBuilder.append(line); stringBuilder.append(NEW_LINE); ... |
String | read(File file) read return read(file, false);
|
List | read(File file) read if (file != null) { try { return readFree(file); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); return null; |
String | read(File file, boolean raw) read FileInputStream fis = new FileInputStream(file); byte[] bytes = new byte[fis.available()]; fis.read(bytes); fis.close(); String s = new String(bytes, StringPool.UTF8); if (raw) { return s; } else { ... |
StringBuffer | read(String file) read BufferedReader in = null; StringBuffer sb = new StringBuffer(); String s = null; StringBuffer stringbuffer; try { in = new BufferedReader(new FileReader(file)); while ((s = in.readLine()) != null) sb.append(s).append('\n'); ... |
String | read(String fileName) read return read(new File(fileName)); |