I'm trying to read from a URL, and then print the result.
BufferedReader in = new BufferedReader(
new InputStreamReader(new URL("http://somesite.com/").openStream(), "UTF-8"));
String s = "";
while ((s=in.readLine())!=null) System.out.println(s);
in.close();
It works great most of the time, and prints the website's source. However, my problem is, on specific websites, instead of the source code, it will print out gibberish, such as symbols and other unusual characters.
Is there some property that varies from website to website that would affect how it is read? The page loads just fine in Firefox, and I can view the source there with no problem. If firefox can access the source, I should be able to as well; I'm just not sure why it isn't working...
EDIT: added "UTF-8" to InputStreamReader. All of the strange characters are now question marks...still not working...