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) {
}
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
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!
haha,exactly what i wanted,thanks a lot.keep it up!!
very useful
nolmus buraya aq
kod ararken
ortalik reklam dolmus
Note that this returns the contents on a per-line basis. If you want to just get the whole contents of the file, it's better to use the read() method with a char array buffer.
char array has size limit since array size is int. the max is Integer.MAX_VALUE.
I got timeout exception for this code.
Please sent me a suggestion for my mail Id sivakumar0211@gmail.com
thx!
it works!
thx!
it works!
I agree with your Blog and I will be back to check it more in the future so please keep up your work. I love your content & the way that you write. It looks like you have been doing this for a while now, how long have you been blogging for?
hi friends iam new to android ,how to set text to textview dynamically from server in android.please Help me friends iam strgulling a lot on this issue.
I love your content & the way that you write. It looks like you have been doing this for a while now, how long have you been blogging for?
It loops reading each line, and stores only the LAST line into str?
while ((str = in.readLine()) != null) {
// str is one line of text; readLine() strips the newline character(s)
}
Read 1 line at a time... then destroy that line... while you read each additional line... overwriting it.
When you are done... you only have line 143. The previous 142 lines have been lost.