Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Found reliance on default encoding in FileReader [duplicate]

Tags:

java

findbugs

How can we fix the below issue reported by findBugs:

Found reliance on default encoding in abc.java : new java.io.FileReader(File)

I'm just reading file & Findbug has reported the issue.

Any help is much appreciated!

like image 958
Mike Avatar asked Aug 15 '12 02:08

Mike


1 Answers

use an explicit character encoding when opening a file instead of relying on the platform default (which can change depending on the platform), unless of course, you intend to use the platform default. you can use InputStreamReader to convert a FileInputStream to a Reader using an explicit character encoding.

like image 70
jtahlborn Avatar answered Oct 15 '22 13:10

jtahlborn