List of utility methods to do Text File Read by Charset
String | readStreamToString(InputStream stream, Charset encoding) read Stream To String StringBuilder builder = new StringBuilder(); InputStreamReader reader = new InputStreamReader(stream, encoding); char[] buffer = new char[BUFFER_SIZE]; int length; while ((length = reader.read(buffer)) != -1) { builder.append(buffer, 0, length); reader.close(); ... |
String | readString(DataInput input, int length, Charset charset) reads from current position. byte[] data = new byte[length]; input.readFully(data); return new String(data, charset); |
String | readString(final InputStream in, final Charset charset) Reads all data from the given stream as character data in the given character set and closes it on completion or errors. final Reader reader = new InputStreamReader(in, charset); final StringBuilder builder = new StringBuilder(); final CharBuffer buffer = CharBuffer.allocate(2048); try { while (reader.read(buffer) > -1) { buffer.flip(); builder.append(buffer); } finally { closeQuietly(reader); return builder.toString(); |
String | readString(final InputStream in, final Charset charset) Reads a string from an input stream. return readString(new InputStreamReader(new BufferedInputStream(in), charset)); |
String | readString(final InputStream input, final Charset charset) read String final byte[] bytes = readBytes(input, 4096); return new String(bytes, charset); |
String | readString(InputStream in, int numBytes, Charset encoding) Read numBytes from an InputStream and encode them into a String. byte[] bytes = readBytes(in, numBytes); return new String(bytes, encoding); |
String | readString(InputStream in, String charset) read String try { return new String(readAll(in), charset); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); |
String | readStringFromStream(InputStream stream, Charset charset) read String From Stream StringBuilder stringBuilder = new StringBuilder(); Reader reader = new InputStreamReader(stream, charset); char[] buffer = new char[1024]; while (true) { int res = reader.read(buffer); if (res == -1) { break; stringBuilder.append(buffer, 0, res); reader.close(); stream.close(); return stringBuilder.toString(); |
String | readTextFile(final String fileNamePath, final String charsetName) Liest Text Datei byte[] text = readFile(fileNamePath); return new String(text, charsetName); |
String | readTextStream(InputStream is, Charset charset) read Text Stream ByteArrayOutputStream baos = new ByteArrayOutputStream(1024 * 4); redirectInput(is, baos, new byte[1024 * 2], -1); byte[] bytes = baos.toByteArray(); baos = null; return new String(bytes, charset); |