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

StringreadAsUTF8(String text)
read As UTF
if (text == null)
    return null;
return new String(text.getBytes(ENC_LATIN1), ENC_UTF8);
ListreadLines(File inputFile)
read lines from the given inputFile
List<String> list = Files.readAllLines(inputFile.toPath(), Charset.defaultCharset());
return list;
StringreadRawUTF8Bytes(final byte[] bytes)
Generates a String that is populated with the UTF-8 decoding of the provided byte array.
return new String(bytes, StandardCharsets.UTF_8);
StringreadResourceUtf8(Class contextClass, String filename)
Loads a file (specified relative to the contextClass) as a string, assuming UTF-8 encoding.
return resourceToString(getResource(contextClass, filename));
StringreadStringFromUTF8Stream(InputStream is)
read String From UTF Stream
return readString(is, StandardCharsets.UTF_8.name());
StringreadStringUTF16LE(byte[] var0, int var1, int var2)
read String UTFLE
int var3 = 0;
for (int var4 = 0; var4 < var2; ++var4) {
    if (var0[var1 + var4] == 37) {
        var3 = var4;
        break;
return new String(var0, var1, var3, Charset.forName("UTF-16LE"));
...
ListreadTextFile(File inputFile)
read Text File
return readText(new InputStreamReader(new FileInputStream(inputFile), Charset.forName("UTF-8")));
StringreadUTF8(DataInput buf)
Reads an UTF8 string from a byte buffer.
final int len = readVarInt(buf);
final byte[] bytes = new byte[len];
buf.readFully(bytes);
return new String(bytes, StandardCharsets.UTF_8);
StringreadUtf8String(DataInputStream in)
Reads a UTF-8 encoded string from the buffer.
int len = in.readUnsignedShort();
byte[] bytes = new byte[len];
in.readFully(bytes);
return new String(bytes, CHARSET_UTF8);
StringreadUTFByteArrayFromDataInput(final DataInput in)
Reads a string from the given DataInput.
int length = in.readInt();
byte[] byteArray = new byte[length];
in.readFully(byteArray);
return new String(byteArray, StandardCharsets.UTF_8);