gpt4 book ai didi

java - 使用 map 高程 API

转载 作者:行者123 更新时间:2023-12-01 16:22:43 26 4
gpt4 key购买 nike

在我的应用程序中,当我尝试使用“ map 高程 API”获取高程时,我得到的答案看起来像中文答案。我的要求是: My request

通过以下代码查询API返回的结果:

            try {
url = new URL(arg0[0]);
urlConnection = (HttpURLConnection)url.openConnection();
try {
urlConnection.setRequestMethod("POST");
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
os=urlConnection.getOutputStream();
bw=new BufferedWriter(new OutputStreamWriter(os,"UTF_16"));
bw.flush();
bw.close();
is = urlConnection.getInputStream();
br = new BufferedReader(new InputStreamReader(is, "UTF_16"));
while ((ligneRéponse = br.readLine()) != null) {
if(ligneRéponse.length()!=0) {e
if (ligneRéponse.contains("<elevation>")) {
if (ligneRéponse.contains("<elevation>")) {
altitude = Double.parseDouble(ligneRéponse.substring(ligneRéponse.indexOf("<elevation>") + 11, ligneRéponse.indexOf("</elevation>")));
} else {
altitude = -10000;
}
}
}
}
is.close();
} finally {
urlConnection.disconnect();
}
} catch (IOException e) {
e.printStackTrace();
}

return(altitude);

直到最近,这段代码都运行得很好。现在,我在 ligneRéponse 变量中得到的内容如下:㰿硭氠症牳楯渽∱⸰∠敮捯摩涌㴢啔䘭㠢㼾਼䕬敶准备楯湒敳灯湳放ਠ㱳瑡瑵操佋㰯獴梦畳㸊‼牥猎汴㸊†㱬潣梦楯浑ਠ†㱬梦㸴㔮㠱ㄲ㠰㜼⽬梦㸊†‼汮朾㌮〱㠴㘹㔼⽬涌㸊†㰯汯捡莹潮㸊†㱥汥痴莹潮㸸〳⸶㌶㜱㠸㰯敬敶声楯浑ਠ‼牥獯汵莹潮㸱㤮〸㜹〴〼⽲敳潬晓楯浑ਠ㰯牥猎汴㸊㰯䕬敶啶啶啶啶啶啶啶啶敶潬楯湒敳灯湳放�

如果我直接从网络浏览器启动请求,结果会正确地用英语编写,就像以前一样......

有谁知道如何在我的应用程序中获得可以理解的答案?

最佳答案

答案以 UTF-8 形式出现,但您试图将其解释为 UTF-16。

关于java - 使用 map 高程 API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62228559/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com