Botre Posted August 2, 2016 Share Posted August 2, 2016 If I set references to the table with all of the data to null after pulling the information from it, will it free all allocated memory? map.clear() please. Quote Link to comment Share on other sites More sharing options...
Redfr3sh Posted August 31, 2016 Share Posted August 31, 2016 how often is this updated every 15 minutes? Quote Link to comment Share on other sites More sharing options...
Redfr3sh Posted August 31, 2016 Share Posted August 31, 2016 (edited) How do you change for average buy and average sell soz double post Edited August 31, 2016 by RedFr3sh Quote Link to comment Share on other sites More sharing options...
Explv Posted August 31, 2016 Author Share Posted August 31, 2016 How do you change for average buy and average sell soz double post The data is retrieved in the format: {"overall":369,"buying":372,"buyingQuantity":108551,"selling":367,"sellingQuantity":121543} Using a URL such as: http://api.rsbuddy.com/grandExchange?a=guidePrice&i=1515 The following method retrieves the "overall" value: private Optional<Integer> getRSBuddyPrice(){ try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); } catch(Exception e){ e.printStackTrace(); } return Optional.empty(); } If you wanted to retrieve all of these data items, you can just alter this method to instead return a Map<String, Integer>, and instead of just doing: Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); Which gets the "overall" value, you can do this for "buying", "selling" etc. and add it to the Map. I will write this up when I get home if you aren't sure how to do it. 1 Quote Link to comment Share on other sites More sharing options...
Redfr3sh Posted September 1, 2016 Share Posted September 1, 2016 can you write it up please bro if you could do i need two different matches Quote Link to comment Share on other sites More sharing options...
jython Posted September 19, 2016 Share Posted September 19, 2016 These snippets are wonderful. I was just getting around to writing a fighter and needed to write in my loot calculator. Thanks so much for sharing this. 1 Quote Link to comment Share on other sites More sharing options...
progamerz Posted October 2, 2016 Share Posted October 2, 2016 sigh perhaps you should read up on the Java Garbage Collector then. If you are really concerned about memory usage, then perhaps you should use a profiler to see how much memory, and where the memory is being used. It isn't really a concern though. It's just a Map containing a few objects.. How can i get only price? Quote Link to comment Share on other sites More sharing options...
Juggles Posted November 2, 2016 Share Posted November 2, 2016 Great snippet Quote Link to comment Share on other sites More sharing options...
Butters Posted November 21, 2016 Share Posted November 21, 2016 Any idea why this worked perfectly for me for a couple of first times and started not to find the items I'm looking for? Even tried by replacing the getRSBuddyPrice() method with getOSRScurrentPrice(). Quote Link to comment Share on other sites More sharing options...
Explv Posted November 27, 2016 Author Share Posted November 27, 2016 Any idea why this worked perfectly for me for a couple of first times and started not to find the items I'm looking for? Even tried by replacing the getRSBuddyPrice() method with getOSRScurrentPrice(). I noticed there was a slight error in one of the regex patterns, it may have been causing issues for you. I have fixed it in the original post. Quote Link to comment Share on other sites More sharing options...
Trivial Posted December 21, 2016 Share Posted December 21, 2016 How can i get only price? Map<String, ExchangeItem> exchangeItems = new RSExchange().getExchangeItems("Your item"); exchangeItems.get("Your item").getPrice(); Quote Link to comment Share on other sites More sharing options...
progamerz Posted December 21, 2016 Share Posted December 21, 2016 Map<String, ExchangeItem> exchangeItems = new RSExchange().getExchangeItems("Your item"); exchangeItems.get("Your item").getPrice(); i got it working long time ago, but anyways thanks. Quote Link to comment Share on other sites More sharing options...
S3R0 Posted December 22, 2016 Share Posted December 22, 2016 If I may ask, is there a reason why java.util.Optional is unresolveable? Maybe it's just me? Quote Link to comment Share on other sites More sharing options...
Explv Posted December 22, 2016 Author Share Posted December 22, 2016 If I may ask, is there a reason why java.util.Optional is unresolveable? Maybe it's just me? Make sure the language level of your IDE is set to Java 8, because Optionals were a new feature introduced in Java 8. Quote Link to comment Share on other sites More sharing options...
S3R0 Posted December 22, 2016 Share Posted December 22, 2016 Make sure the language level of your IDE is set to Java 8, because Optionals were a new feature introduced in Java 8. Aha, that explains that then. I was still using 1.7.0. Thanks! Quote Link to comment Share on other sites More sharing options...