The problem is in these lines:
Random rn = new Random();
...
int i = rn.nextInt() % n;
...
tempURL = new URL("http://miniz.co/RageToonApp/Images/" + rn + ".jpg");
You are calculating i
but instead of using it in the URL, you're using rn
instead. By default, this calls Random.toString() which contains characters (in this case, a @
) that are illegal in URLs.
To fix this you should change the last line to:
tempURL = new URL("http://miniz.co/RageToonApp/Images/" + i + ".jpg");