Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:49:43+00:00 2026-05-30T20:49:43+00:00

Im on quite a basic level of android development. I would like to get

  • 0

Im on quite a basic level of android development.

I would like to get text from a page such as “http://www.google.com”. (The page i will be using will only have text, so no pictures or something like that)
So, to be clear: I want to get the text written on a page into etc. a string in my application.

I tried this code, but im not even sure if it does what i want.

URL url = new URL(/*"http://www.google.com");
URLConnection connection = url.openConnection();
// Get the response     
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = "";

I cant get any text from it anyhow. How should I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:49:45+00:00Added an answer on May 30, 2026 at 8:49 pm

    From the sample code you gave you are not even reading the response from the request. I would get the html with the following code

    URL u = new URL("http://www.google.com");
    URLConnection conn = u.openConnection();
    BufferedReader in = new BufferedReader(
                            new InputStreamReader(
                                conn.getInputStream()));
    StringBuffer buffer = new StringBuffer();
    String inputLine;
    while ((inputLine = in.readLine()) != null) 
        buffer.append(inputLine);
    in.close();
    System.out.println(buffer.toString());
    

    From there you would need to pass the string into some kind of html parser if you want only the text. From what I’ve heard JTidy would is a good library for this however I have never used any Java html parsing libraries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem is quite basic. I have a JTable showing cached data from a
Noob question. I have been programming at basic level for quite a while but
This is a very basic question...quite embarassing, but here goes: I have a Stopwatch
I'm quite confused about the basic concepts of a Hash table. If I were
Quite simple really: var req:URLRequest=new URLRequest(); req.url=http://somesite.com; var header:URLRequestHeader=new URLRequestHeader(my-bespoke-header,1); req.requestHeaders.push(header); req.method=URLRequestMethod.GET; stream.load(req); Yet,
Quite often, in programming we get situations where null checks show up in particularly
Today I had an interview on which I asked candidate quite usual and basic
This is probably something quite basic. I am trying to implement AdWhirl into my
I know this question is quite basic but since there is lot of confusion
I would like to clamp a value x to a range [a, b] :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.