List of utility methods to do InputStreamReader Read
String | load(File file, String encoding) Read a text file into a string. FileInputStream fis = new FileInputStream(file); InputStreamReader reader = new InputStreamReader(fis, encoding); StringBuffer strBuf = new StringBuffer(); char[] buffer = new char[4096]; int i = 0; try { while ((i = reader.read(buffer)) != -1) strBuf.append(buffer, 0, i); ... |
T | load(final File file, final Class load InputStream stream = null; try { stream = new FileInputStream(file); if (stream != null) return load(stream, clazz); } finally { try { if (stream != null) ... |
char[] | load(String fileName) load File file = new File(fileName); final int size = (int) file.length(); char[] buffer = new char[size]; try (InputStreamReader in = new InputStreamReader(new FileInputStream(file))) { int readSize = in.read(buffer); if (readSize < size) { buffer = Arrays.copyOf(buffer, readSize); return buffer; } catch (IOException e) { return null; |
String | loadAsText(InputStream in, String encoding, int bufferSize) load As Text InputStreamReader reader = new InputStreamReader(in, encoding); char[] buffer = new char[bufferSize]; int offset = 0; for (;;) { int remain = buffer.length - offset; if (remain <= 0) { char[] newBuffer = new char[buffer.length * 2]; System.arraycopy(buffer, 0, newBuffer, 0, offset); ... |
Object[] | readFile(Class cl, String filename) Lire un fichier texte # partir Retourne un liste de chaque ligne Object[] res = null; ArrayList list = new ArrayList(); String nextLine = null; try { BufferedReader in = new BufferedReader( new InputStreamReader(cl.getResourceAsStream("/res/" + filename))); while ((nextLine = in.readLine()) != null) list.add(nextLine); ... |
String | readFile(Class> cls, String filename) read File InputStream stream = cls.getResourceAsStream(filename); if (stream != null) { StringBuffer fileData = new StringBuffer(); BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); char[] buf = new char[1024]; for (int bufLen = reader.read(buf); bufLen != -1; bufLen = reader.read(buf)) { String readData = String.valueOf(buf, 0, bufLen); fileData.append(readData); ... |
String | readFile(ClassLoader classloader, String filename) Just for reading a damn file from a package using class loader. InputStream istream = classloader.getResourceAsStream(filename); if (istream == null) return null; BufferedReader reader = new BufferedReader(new InputStreamReader(istream)); StringBuilder sb = new StringBuilder(); String line = null; try { while ((line = reader.readLine()) != null) { ... |
String | readFile(File f) read File BufferedReader reader = null; StringBuilder sb = new StringBuilder(); try { reader = new BufferedReader(new InputStreamReader(new FileInputStream(f), "utf-8")); String line = null; while ((line = reader.readLine()) != null) sb.append(line); } catch (Exception e) { ... |
String | readFile(File f) read File return read(new FileInputStream(f)); |
String | readFile(File f) read File return readStream(new InputStreamReader(new FileInputStream(f), "UTF-8")); |