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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:04:50+00:00 2026-05-25T12:04:50+00:00

I’m having some problems with an InputStream. I’m writing a little Android application and

  • 0

I’m having some problems with an InputStream. I’m writing a little Android application and part of it has to fetch HTML code from a website. Generally, it works fine, but sometimes (usually the second time it’s called, but it may also take a few tries to reproduce this) it will just skip the InputStream (I noticed this since it takes a few seconds while debugging, but every time it fails it will just immediately skip to the next line). Any ideas what could be causing this and how to fix it?

    private class fetchdata extends AsyncTask<Void, Void, Void> {
            public Activity activity;      
            public fetchdata(Activity a)
            {
                activity = a;
            }  
            protected Void doInBackground(Void...voids)
            {
                String[] page = new String[16384]; //Number is just for testing, don't worry
                try {
                                page = executeHttpGet();
                        } catch (Exception e) {
                                page[0] = "Error";
                        }
                displayFetchedData(page);
                return null;
            }
    public String[] executeHttpGet() throws Exception {
         URL u;
        InputStream is = null;
        DataInputStream dis = null;
        String s;
        int i = 0;
        int hostselection;
        boolean skip;
        String[] page = new String[16384];
        String[] serverurls = new String[2];
        addSecurityException();
        SharedPreferences dataprefs = getSharedPreferences("serverdata", Context.MODE_PRIVATE);        
        hostselection = dataprefs.getInt("selectedhost", 0);
        SharedPreferences preferences;
        preferences = PreferenceManager.getDefaultSharedPreferences(activity);
        serverurls[0] = preferences.getString("server01", "");
        serverurls[1] = preferences.getString("server02", "");
        for (int j = 0; j < 2; j++)
        {
         skip = false;
         if (j == 0)
         {
                         if (hostselection == 0 || hostselection == 1)
                             {
                                 Authenticator.setDefault(new MyAuthenticator(activity, false));
                             }
                         else
                         {
                                 skip = true;
                         }
         }
         if (j == 1)
         {
                         if (hostselection == 0 || hostselection == 2)
                             {
                                 Authenticator.setDefault(new MyAuthenticator(activity, true));
                             }
                         else
                         {
                                 skip = true;
                         }
         }
         if (skip == false)
         {
                         try {
                            u = new URL(serverurls[j]);
                            is = u.openStream();        //LINE IN QUESTION
                            dis = new DataInputStream(new BufferedInputStream(is));
                            while ((s = dis.readLine()) != null)
                            {
                                if (s.length() > 18)
                                {
                                        page[i] = s;
                                        i++;
                                }
                            }
                         }
                         catch (IOException ioe)
                         {
                                 ioe.printStackTrace();
                         }
                         is.close();
                      }
        }
        return page;
   }
  • 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-25T12:04:51+00:00Added an answer on May 25, 2026 at 12:04 pm

    Unrelated, but you aren’t closing the DataInputStream.

    Tell us more about the skipping. Is an exception raised? Is it possible that when you are running it outside of debug mode it is somehow referencing stale class files? The only thing I can imagine is that somehow your debug and normal classes are somehow different.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I've got a string that has curly quotes in it. I'd like to replace
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.