声纳问题:不应使用依赖于默认系统编码的类和方法

时间:2017-09-19 09:47:11

标签: java sonarqube inputstream

我在使用声纳检查代码的代码质量时遇到错误。这是错误

Classes and methods that rely on the default system encoding should not be used : Remove this use of constructor "InputStreamReader(InputStream)"

这是代码

private StringBuilder getServerResponse(URLConnection connection) throws IOException {
        final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        String inputLine;
        final StringBuilder response = new StringBuilder();
        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();
        return response;
    }

我在下面的行中收到此错误: -

final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));

我试图找到解决方案,但没有取得任何成功。 任何指针都会有所帮助。

1 个答案:

答案 0 :(得分:0)

WebSettings mWebSettings = mWebView.getSettings();
mWebSettings.setJavaScriptEnabled(true); // Done above
mWebSettings.setDomStorageEnabled(true); // Try
mWebSettings.setSupportZoom(false);
mWebSettings.setAllowFileAccess(true);
mWebSettings.setAllowContentAccess(true);

尝试使用此功能。 有关此问题的更多信息:https://stackoverflow.com/a/22115303