1

It gives me a white screen when I run this code and the cause of this white screen is the first line in the try block:

try {
    result = task.execute("https://www.hollywoodreporter.com/lists/international-womens-day-2017-feminist-quotes-25-celebrities-983702").get();
    
    String[] splitResult= result.split("</div><figcaption class");
    
    Pattern p =Pattern.compile(" src=\" (.*?) \"/> ");
    Matcher m= p.matcher(splitResult[1]);
    while (m.find()) { clecbUrls.add(m.group(1)); }
    
    p =Pattern.compile("content=\" (.*?) \"/> ");
    m= p.matcher(splitResult[1]);
    while (m.find()) { clecbNames.add(m.group(1)); }
                 
    Random random =new Random();
    chosenCeleb=random.nextInt( clecbUrls.size());
 } 
 catch (ExecutionException e) {
     e.printStackTrace();
     System.out.println("it crashed");
 }
 catch (InterruptedException e) {
     e.printStackTrace();
     System.out.println("crashed");
 }
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0

First of all you should fix your styling so that the first line is inside the code block.

Secondly it does not crash since you should get an error from the catch blocks. This leads to the idea that your task.execute is returning an empty String. It would explain why there is neither an errror nor content. You need to show us the Code of doInBackground if you want more information. Also i do not understand why you call get on the result of execute. Can you not use doInBackground to return whatever you want already?

Tobias
  • 383
  • 2
  • 12