[英]how to read data from a json file which is specified with a particular URL using java
URL url = new URL("http://rate-exchange.appspot.com/currency?from=USD&to=EUR&q=3");
URLConnection yc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
}
in.close();
Gson gson = new Gson();
Rate r = gson.fromJson(inputLine,Rate.class);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.