HttpURLConnection returns 正常 unicode 符号仅当 运行 在 java studio(Intellij Idea)中时

HttpURLConnection returns normal unicode symbols only when run inside java studio(Intellij Idea)

当我编译成 jar 时 returns 不同的符号,但在 Intellij 中它运行完美,符合我的需要。

URL url = new URL("http://myurl.here/file.php");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("User-Agent", "Mozilla/5.0");
con.setRequestProperty("Accept-Charset", "UTF-8");

BufferedReader in = new BufferedReader(
        new InputStreamReader(con.getInputStream()));
String line;
StringBuffer response = new StringBuffer();

while ((line = in.readLine()) != null) {
    response.append(line);
}
in.close();

在此之后,我将结果添加到 Javafx 标签。这里显示编译前完美

哇...我尝试了另一种方法,效果非常好! :D

URL url = new URL("http://url/file.php");
URLConnection connection = url.openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
connection.setRequestProperty("Accept-Encoding", "identity");
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");
BufferedReader br = new BufferedReader(new InputStreamReader(
        connection.getInputStream(), "UTF-8"));
String input;
String line = "";
while((input=br.readLine()) !=null){
    line = line + input;
}