所以这是我的问题。我正在使用httpurlconnection
. 该 json 包含德语特殊字符 (äöü)。在 NetBeans 内部,一切都很好。当我构建 jar 并运行它时,“Silberanhänger”变为“Silberanhänger”。这是代码,里面没什么特别的
URL url = new URL("jsonUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setUseCaches(false);
con.setRequestProperty("Accept-Language","de-de,de;q=0.8,en-us;q=0.5,en;q=0.3");
con.setRequestProperty("Cookie","s="+session);
try (BufferedReader bf = new BufferedReader(new InputStreamReader(
con.getInputStream()))) {
jsonRepresentation = bf.readLine(); //only 1 line
}
con.disconnect();
System.out.println(jsonRepresentation) // "ä" in IDE, "ä" in Live