List of utility methods to do InputStreamReader Read
List | readFileList(File file) read File List List<File> files = new ArrayList<File>(); String path = file.getParentFile().getAbsolutePath(); BufferedReader content = new BufferedReader(new InputStreamReader(new FileInputStream(file))); String line = content.readLine(); while (line != null) { files.add(new File(path + "/" + line)); line = content.readLine(); return files; |
String | readFileOneLine(String filename, String keyInLine) read File One Line File f = new File(filename); if (!f.exists()) return null; FileInputStream fis = null; InputStreamReader fsr = null; BufferedReader reader1 = null; String line; try { ... |
Reader | readFileOrResource(String source) read File Or Resource Stream<Function<String, InputStream>> suppliers = Stream.of((path) -> { try { return new FileInputStream(path); } catch (FileNotFoundException e) { return null; }, (path) -> Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/openqa/grid/common/" + path), ... |
String | readFiles(String[] files, String encoding) read Files StringBuffer buffer = new StringBuffer(); for (String pathname : files) { File file = new File(pathname); buffer.append(readFile(file, encoding)); return buffer.toString(); |
StringBuffer | readFileSB(File f) read File SB InputStream in = new FileInputStream(f); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); StringBuffer sb = new StringBuffer(); try { readFile(reader, sb); } finally { reader.close(); return sb; |
ArrayList | readFileToLines(File file) Returns the contents of file as a List of the lines as defined by java.io.BufferedReader#readLine() (i.e. BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); ArrayList<String> lines = new ArrayList<>(); String line; while ((line = reader.readLine()) != null) { lines.add(line); return lines; |
List | readFileToList(String fileName, String codeing) read File To List List<String> list = new ArrayList<String>(); try { BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(fileName), codeing)); String data = null; do { data = reader.readLine(); if (data == null) ... |
Set | readFileToSet(String filePath, String fileEncoding) read File To Set if (fileEncoding == null) { fileEncoding = "utf-8"; File file = new File(filePath); BufferedReader br = null; String line = null; Set<String> lineSet = new HashSet<String>(); try { ... |
String | readFileUtf8(IFile file) read File Utf if (file.isAccessible()) { InputStream inputStream = file.getContents(true); try { return readStringUtf8(inputStream); } finally { inputStream.close(); return null; |
String | readFileWithThrow(IFile in) read File With Throw InputStream contents = in.getContents();
return readStream(contents);
|