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 9162563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:14:26+00:00 2026-06-17T14:14:26+00:00

This is the code, which has to load a page and store it in

  • 0

This is the code, which has to load a page and store it in string[]. I dont understand the problem as it is not loading the page and it is throwing no errors.

If any one knows any better ways to send a http request then please post it or please tell me the problem.

 //some code    
    btnShowLocation.setOnClickListener(new View.OnClickListener() {
                int j=0;
                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub

                    new MyTask().execute();});     
    //some code

    private class MyTask extends AsyncTask<Void, Void, Void> {
                    @Override
                    protected Void doInBackground(Void... params) {
                        // TODO Auto-generated method stub

                        try {

                            String ssr="";
                            URL n = new URL("http://maps.google.co.in/maps?hl=en&q=nagpur+to+pune");
                            URLConnection nc = null;
                            nc = n.openConnection();
                            BufferedReader in = null;
                            in = new BufferedReader(new InputStreamReader(nc.getInputStream()));
                            String inputLine;
                            while ((inputLine = in.readLine()) != null) {
                                ssr+=inputLine;
                            }

                            Document doc = Jsoup.parse(ssr);
                            Elements el = doc.getElementsByClass("dir-mrgnr");
                            String str = el.text();
                            str = str.replaceAll("[0-9]+[.] ", "\n");
                            string = str.split("\n");
                        } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                        return null;
                    }

                    @Override
                    protected void onProgressUpdate(Void... values) {
                        // TODO Auto-generated method stub
                        super.onProgressUpdate(values);
                        Toast.makeText(
                                getApplicationContext(),
                                "in Background",
                                Toast.LENGTH_LONG).show();
                        speakOut("not Working");
                        //speakOut("work in progress");
                    }

                    @Override
                    protected void onPostExecute(Void result) {
                        // TODO Auto-generated method stub

                        super.onPostExecute(result);

                    }

                }
  • 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-06-17T14:14:27+00:00Added an answer on June 17, 2026 at 2:14 pm

    You dont need to download the page and parse it then.

    List<String> list = new ArrayList<>(); // Better than an array
    
    Document doc = Jsoup.connect("http://maps.google.co.in/maps?hl=en&q=nagpur+to+pune").get(); // Connect to url and parse its conntent
    Elements el = doc.select("*.dir-mrgnr"); // Every tag with 'dir-mrgnr' class - or use getElementsByClass() as you did
    
    for( Element element : el )
    {
        list.add(element.text());
    }
    

    Btw. dont use += on a String in a loop; use a StringBuilder instdead!

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

Sidebar

Related Questions

index.php has this jquery code which loads notifications.inc.php into a div on the page
I'm using a tutorial plugin - http://particlebits.com/code/jquery-tutorial/ which has this code attached to the
I was checking out this question which has this code - (NSArray *) percentagesRGBArray:(float[])
In my application I use the ShinyBlue.xaml resource dictionary which has this code for
I have progress.js file which has the following code $('#text_area_input').keyup(function() { var text_area_box =$(this).val();//Get
This question has two parts. Part 1. Yesterday I had some code which would
I'm working with a Google Maps example code , this : http://www.wolfpil.de/v3/drag-from-outside.html which has
I have a home page HomeController this loads the home view which has some
I have this code which permits me to reload the content of a page
I created a web page for viewing images. This page has some other code

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.