List of utility methods to do BufferedReader Read
List | readFileAsListOfString(String fileName, String splitBy) read File As List Of String File file = new File(fileName); BufferedReader buffer = new BufferedReader(new FileReader(file)); String line; List<String> data = new ArrayList<>(); while ((line = buffer.readLine()) != null) { data = Arrays.asList(line.split(splitBy)); return data; ... |
List | readFileAsListOfStrings(String filename) Open and read a file, and return the lines in the file as a list of Strings. List<String> records = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader(new FileReader(filename)); String line; while ((line = reader.readLine()) != null) { records.add(line); reader.close(); ... |
List | readFileAsListOfStrings(String filename) Open and read a file, and return the lines in the file as a list of Strings. List<String> records = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new FileReader(filename)); String line; while ((line = reader.readLine()) != null) { records.add(line); reader.close(); return records; ... |
String | readFileAsText(String path) read File As Text FileReader reader = new FileReader(path); BufferedReader br = new BufferedReader(reader); try { String text = ""; String line = null; while ((line = br.readLine()) != null) { text = text + line + "\n"; return text; } finally { br.close(); reader.close(); |
Set | readFileByChar(String path) read File By Char Set<String> datas = new HashSet<String>(); FileReader fr = new FileReader(path); BufferedReader br = new BufferedReader(fr); String line = null; while ((line = br.readLine()) != null) { datas.add(line); br.close(); ... |
String | readFileContext(File fileToRead) Read the context of a file. try { BufferedReader bf = new BufferedReader(new FileReader(fileToRead)); StringBuffer sb = new StringBuffer(); String aline = bf.readLine(); while (aline != null) { sb.append(aline); sb.append(LINE_SEP); aline = bf.readLine(); ... |
String | readFileEncoding(String file) read File Encoding FileReader fr; String encoding = null; try { fr = new FileReader(file); BufferedReader br = new BufferedReader(fr); char[] buffer = new char[100]; br.read(buffer); StringBuffer st = new StringBuffer(new String(buffer)); ... |
boolean | readFileGdeHash(File gdeFile, ArrayList name, ArrayList seq) read File Gde Hash return readFastaFileToArray(gdeFile, "#", name, seq); |
String | readFilePathToString(String filePath) read File Path To String StringBuffer fileData = new StringBuffer(2048); BufferedReader reader = new BufferedReader(new FileReader(filePath)); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; ... |
LinkedHashMap | readFileToHashMap(String filePath, String separator, boolean valueFirst) Method to read a properties file into a LinkedHashMap . if (separator == null) { separator = "="; List<String> lines = readFileToLinesList(filePath); LinkedHashMap<String, String> propertiesMap = new LinkedHashMap<>(); for (String line : lines) { line = line.trim(); if (line.length() == 0) { ... |