Java UTF32Reader-class And Method Code Example

I apologize, but there is no such class as "UTF32Reader" in the Apache Commons IO library. It seems that you might be confusing it with other class or package. Apache Commons IO focuses on providing utility classes for file and I/O operations, and it doesn't have a class specifically for reading UTF-32 encoded text.

Java provides the InputStreamReader class which can be used to read text from an InputStream. The InputStreamReader class can be used to specify the character encoding of the input stream. To read UTF-32 encoded text, you can use the InputStreamReader class with the "UTF-32" character encoding.

Here is an example of using the InputStreamReader class to read UTF-32 encoded text from a file:


public class UTF32ReaderExample {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("file.txt");
        InputStreamReader reader = new InputStreamReader(fis, "UTF-32");
        int c;
        while ((c = != -1) {
            System.out.print((char) c);

In this example, we first create a FileInputStream object to read the contents of a file named "file.txt". We then create an InputStreamReader object and pass it the FileInputStream object and the "UTF-32" character encoding.

We then use a while loop to read the contents of the file one character at a time. The read() method returns -1 when the end of the file is reached. We then cast each character to a char and print it to the console. Finally, we close the reader to release the resources.