Found default encoding dependency in FileReader

How can we fix the problem described below with findBugs:

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

I just read the file and Findbug reported this problem.

Any help is much appreciated!

+5
source share
1 answer

use explicit character encoding when opening a file instead of relying on the default platform (which may vary depending on the platform) unless, of course, you intend to use the default platform. you can use InputStreamReaderto convert FileInputStreamto Readerusing explicit character encoding.

+3
source

All Articles