List of utility methods to do FileReader Create
StringBuffer | readTextFile(String fileName, boolean newline) read Text File File file = new File(fileName); if (!file.exists()) { throw new FileNotFoundException(); StringBuffer buf = new StringBuffer(); BufferedReader in = null; try { in = new BufferedReader(new FileReader(file)); ... |
String | readTextFile(String fileName, String enc) Reads a character file into a string. String lineSep = System.getProperty("line.separator"); StringBuffer retVal = new StringBuffer(); try { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), enc)); String line = null; while ((line = in.readLine()) != null) { retVal.append(line); retVal.append(lineSep); ... |
String[] | readTextFile(String filePath) read Text File BufferedReader br = new BufferedReader(new FileReader(filePath)); ArrayList<String> fileContents = new ArrayList<String>(); String line = br.readLine(); while (line != null) { fileContents.add(line); line = br.readLine(); br.close(); ... |
String | readTextFile(String filePath) read Text File String str = null; BufferedReader br = null; try { br = new BufferedReader(new FileReader(filePath)); StringBuilder sb = new StringBuilder(); String line = br.readLine(); while (line != null) { sb.append(line); ... |
String | readTextFile(String filePath) Read a text file and return its content as string. File file = new File(filePath); StringBuffer contents = new StringBuffer(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String text = null; while ((text = reader.readLine()) != null) { contents.append(text).append(System.getProperty("line.separator")); ... |
String | readTextFile(String fullPathFilename) Method readTextFile. StringBuilder sb = new StringBuilder(1024); BufferedReader reader = new BufferedReader(new FileReader(fullPathFilename)); char[] chars = new char[1024]; int numRead = 0; while ((numRead = reader.read(chars)) > -1) { sb.append(String.valueOf(chars, 0, numRead)); reader.close(); ... |
String | readTextFile(String path) Reads the specified text file and returns their contents in a String File file = new File(path); if (!file.exists()) { file.createNewFile(); return ""; BufferedReader reader = new BufferedReader(new FileReader(file)); StringBuilder content = new StringBuilder(); String line = ""; ... |
String | readTextFile(String path) read Text File String newLine = System.getProperty("line.separator"); StringBuffer sb = new StringBuffer(); BufferedReader input = new BufferedReader(new FileReader(path)); String line; while (null != (line = input.readLine())) { if (sb.length() > 0) sb.append(newLine); sb.append(line); ... |
String | readTextFile(String text_file_name) read Text File BufferedReader br = new BufferedReader(new FileReader(new File(text_file_name))); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) buffer.append(line + "\n"); br.close(); return buffer.toString(); |
String | readTextFile(String text_file_name) read Text File BufferedReader br = new BufferedReader(new FileReader(new File(text_file_name))); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = br.readLine()) != null) buffer.append(line + "\n"); br.close(); return buffer.toString(); |