How to read a UTF-8 file in Java
In Java, the InputStreamReader accepts a charset to decode the byte streams into character streams. We can pass a StandardCharsets.UTF_8 into the InputStreamReader constructor to read data from a UTF-8…
Favourite tutorials for developers
In Java, the InputStreamReader accepts a charset to decode the byte streams into character streams. We can pass a StandardCharsets.UTF_8 into the InputStreamReader constructor to read data from a UTF-8…
In Java, the OutputStreamWriter accepts a charset to encode the character streams into byte streams. We can pass a StandardCharsets.UTF_8 into the OutputStreamWriter constructor to write data to a UTF-8…
In Java, we can use str.getBytes(StandardCharsets.UTF_8) to convert a String into a byte. And we can use new String(bytes, StandardCharsets.UTF_8) to convert byte to a String.