我目前正试图在java(https://api.wynncraft.com/public_api.php?action=items&command=75)
中收到此网址问题是,我可以完美地读取以.json结尾的任何文件,但由于.php(我认为)它不适合这个。 另外,如果有人可以告诉我如何将item_name这样的东西变成我可以使用的变量?会很棒......
我的代码:
URL u;
try {
u = new URL("https://api.wynncraft.com/public_api.php?action=items&command=75");
URLConnection c = u.openConnection();
InputStream r = c.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(r));
for (String line; (line = reader.readLine()) != null;)
System.out.println(line);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}