try { String realname2 = (String) rsname.get(sender); if (realname2 == null) { realname2 = sender; } URL statsurl = new URL("http://hiscore.runescape.com/hiscorepersonal.ws?user1=" + realname2); URLConnection statsconnect = statsurl.openConnection(); InputStream statsin = statsconnect.getInputStream(); PrintWriter statspw = new PrintWriter(new FileWriter("stats.txt")); BufferedReader urlbr = new BufferedReader(new InputStreamReader(statsin)); String inputLine; while ((inputLine = urlbr.readLine()) != null) { statspw.println(inputLine); } statspw.close(); urlbr.close(); } catch (FileNotFoundException e) { System.err.println("FileNotFoundException"); } catch (IOException e) { System.out.println("IOException"); }