Java Utililty Methods UTF8 File Read

List of utility methods to do UTF8 File Read

Description

The list of methods to do UTF8 File Read are organized into topic(s).

Method

BufferedReadergetBufferedUTF8Reader(InputStream inputStream)
Creates a BufferedReader the UTF-8-encoded InputStream
return new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
byte[]getUtf8BytesFromFile(String fileName)
get Utf Bytes From File
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
Reader reader = new InputStreamReader(inputStream);
StringBuffer stringBuffer = new StringBuffer();
char[] buffer = new char[4096];
int len;
while ((len = reader.read(buffer)) > 0) {
    stringBuffer.append(buffer, 0, len);
return stringBuffer.toString().getBytes("UTF-8");
WritergetUtf8FileWriter(String file, boolean append)
get Utf File Writer
return new OutputStreamWriter(new FileOutputStream(file, append), "utf-8");
InputStreamReadergetUTF8InputStreamReader(InputStream stream)
get UTF Input Stream Reader
return getInputStreamReader(stream, StandardCharsets.UTF_8);
BufferedReadergetUTF8Reader(File f)
get UTF Reader
return new BufferedReader(
        new InputStreamReader(new FileInputStream(f), Charset.forName("UTF-8").newDecoder()));
StringloadUTF8(File file)
load UTF
FileInputStream is = new FileInputStream(file);
try {
    return loadUTF8(is);
} finally {
    is.close();
ReadermakeUTF8Reader(InputStream inputStream)
Constructs a new Reader based on the UTF-8 encoding.
return new InputStreamReader(inputStream, UTF_8_CHARSET);
InputStreamReadernewUtf8Reader(final InputStream in)
new Utf Reader
return new InputStreamReader(in, StandardCharsets.UTF_8);
ReaderopenFileReaderUTF8(File file)
open File Reader UTF
return openFileReader(file, "UTF-8");
ListreadAllLines(File inputFile)
read All Lines
List<String> ret = new ArrayList<String>();
String line;
BufferedReader br = null;
try {
    InputStream fis = new FileInputStream(inputFile);
    InputStreamReader isr = new InputStreamReader(fis, Charset.forName("UTF-8"));
    br = new BufferedReader(isr);
    while ((line = br.readLine()) != null) {
...