InputStreamReader fileData = new InputStreamReader(file); 以前一直都是这样写,但这次用findBugs来检查报了异常,异常如下:Bug: Found reliance on default encoding in trust.cpic.pub.pubfunc.ReadFile(String, int, int): new java.io.InputStreamReader(InputStream)Found a call to a method which will perform a byte to String (or String to byte) conversion, and will assume that the default platform encoding is suitable. This will cause the application behaviour to vary between platforms. Use an alternative API and specify a charset name or Charset object explicitly. Confidence: High, Rank: Of Concern (19)
Pattern: DM_DEFAULT_ENCODING
Type: Dm, Category: I18N (Internationalization)谁能帮我解释下这个异常,要怎么改呢?
Pattern: DM_DEFAULT_ENCODING
Type: Dm, Category: I18N (Internationalization)谁能帮我解释下这个异常,要怎么改呢?
解决方案 »
- JAVA问题,请教高手!
- Myeclpse 的快捷键怎么搞咯!
- Java中foreach的用法?(突然老师说要考这个)我本以为foreach只在C#中才有!
- JS怎么调用JAVA类里面的方法。。在线 急等。。马上给分。。
- 人要死了,jni调用问题 ^^^^^^^^^^^^^^^^^^^^^^,在线等!!
- 深入理解 System.out.println() 的问题。
- jdbc for sqlserver 连接数据库怎么老是出错呀!!
- 散分了!谁有用JNI方法写好的取得Windows机器信息例如CPU主频等信息的程序实例?
- java接口的问题------ 急!!!
- 请哪位高手帮我解答!
- 有没有哪位高手能帮我讲解一下Hash算法,多谢
- 大家帮忙解释下这段程序!!
InputStreamReader fileData = new InputStreamReader(new FileInputStream(file));
你如果不声明编码, 它就会用操作系统默认的编码。 那么你的项目部署到其他服务器上的时候,就有可能发生错误了。 所以他警告你,最好声明一个编码格式。