Getting Text from a URL

try { // Create a URL for the desired page URL url = new URL("http://hostname:80/index.html"); // Read all the text returned by the server BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; while ((str = in.readLine()) != null) { // str is one line of text; readLine() strips the newline character(s) } in.close(); } catch (MalformedURLException e) { } catch (IOException e) { }

Comments

4 Feb 2010 - 1:46am by afroz arshee (not verified)

this code gives us the html formatted text but whr in i want the acctual text
how do i get it plz reply to me as soon as possible to afreaz@gmail.com

1 Mar 2010 - 10:36am by vmollov (not verified)

I tried this and it only works if the URL is on the same domain as the JSP page. Does anyone know a workaround for that problem?
Thank you!

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.