Created
June 16, 2012 18:00
-
-
Save phl0w/2942102 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @author Cakemix | |
| * @author Coma | |
| * @param id | |
| * the item id | |
| * @return the price | |
| * @throws IOException | |
| */ | |
| private int getPrice(int id) throws IOException { | |
| URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + id); | |
| URLConnection con = url.openConnection(); | |
| BufferedReader in = new BufferedReader(new InputStreamReader( | |
| con.getInputStream())); | |
| String line = ""; | |
| String inputLine; | |
| while ((inputLine = in.readLine()) != null) { | |
| line += inputLine; | |
| } | |
| in.close(); | |
| if (!line.contains("mark_price")) | |
| return -1; | |
| line = line.substring(line.indexOf("mark_price\":\"") | |
| + "mark_price\":\"".length()); | |
| line = line.substring(0, line.indexOf("\"")); | |
| return Integer.parseInt(line.replaceAll(",", "")); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment