Java – convert InputStream to InputStreamReader

Last Updated on

This post demonstrates how to convert a file to InputStreamReader.

From FileInputStream

From FileInputStream, we need to convert it to InputStreamReader by pass the object to its constructor.

You can even create an InputStreamReader object that uses a named charset, e.g., “UTF-8”.

Using ClassLoader

The file has to be in the classpath. You may test it more easily with Maven by putting the file in src/main/resource directory.

From FileReader

Yes, you can directly create InputStreamReader object using FileReader. This is the straight-forward solution.


Karl San Gabriel

Professional Software Developer