Advertisement
enissay

Enissay

Oct 2nd, 2014
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. selection.add( new Blah( URL ) ); // create an object and adding it to an arrayList  <= [ERROR SHOWN HERE]
  2.  
  3.  
  4. My class:
  5. public Blah(String _URL) throws MalformedURLException, IOException {
  6.     this.URL = _URL;
  7.    
  8.     Pattern p = Pattern.compile("\\.com\\/[a-z]+\\/(\\d+)");
  9.     Matcher m = p.matcher(getStoreURL());
  10.    
  11.     if (m.find()) {
  12.         System.out.println( "ID = [" + m.group(1) + "]" ); // works fine
  13.  
  14.         this.id = Long.parseLong(m.group(1));
  15.     }
  16.  
  17.         String genreJson = IOUtils.toString(new URL(apiURL + this.id)); // Get the json
  18.  
  19.         ObjectMapper mapper = new ObjectMapper();
  20.  
  21.         JsonNode root = mapper.readTree(genreJson);
  22.  
  23.         setName(root.path(String.valueOf(getId())).path("data").path("name").asText()); // get the name
  24.    
  25.    
  26.    
  27.     System.out.println("In Blah :: getName() " + getName());    // Works fine
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement