Software Development

Java – convert InputStream to InputStreamReader

This post demonstrates how to convert a file to InputStreamReader.

[wp_ad_camp_1]

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”.

[wp_ad_camp_2]

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.

[wp_ad_camp_3]

Loading

Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.


You Might Also Like