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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:18:35+00:00 2026-06-09T09:18:35+00:00

I am trying to retrieve a text file from the internet using the apache

  • 0

I am trying to retrieve a text file from the internet using the apache httpclient. I am using the following code:

        HttpClient httpclient = new DefaultHttpClient();
        HttpGet getHNMR = new HttpGet("http://www.hmdb.ca/labm/metabolites/" + HMDB + "/chemical/pred_hnmr_peaklist/" + HMDB + "_peaks.txt");
        HttpGet getCNMR = new HttpGet("http://www.hmdb.ca/labm/metabolites/" + HMDB + "/chemical/pred_cnmr_peaklist/" + HMDB + "_peaks.txt");

        try {
            responseH = httpclient.execute(getHNMR);
            responseC = httpclient.execute(getCNMR);
        } catch (ClientProtocolException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            System.out.println("client exception");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            System.out.println("ioexception");
        }
        //Generate HNMR peak list
        HttpEntity entityH = responseH.getEntity();
        HttpEntity entityC = responseH.getEntity();;
        try {
            HNMR = EntityUtils.toString(entityH);
            CNMR = EntityUtils.toString(entityC);
        } catch (ParseException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            System.out.println("parseexception");
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            System.out.println("ioexception");
        }
    //Set peak lists to textarea
        HC.setText(CNMR + "\n" + HNMR);

I am getting the following stack trace:

Thread [pool-2-thread-1] (Suspended (exception IllegalStateException))  
ThreadPoolExecutor.runWorker(ThreadPoolExecutor$Worker) line: 1128  
ThreadPoolExecutor$Worker.run() line: 603   
Thread.run() line: 679  

I’m not that familiar with debugging, so I’m not sure what’s exactly happening.

  • 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-09T09:18:36+00:00Added an answer on June 9, 2026 at 9:18 am

    The response body must be consumed before the connection can be used for another request. You should read the response InputStream fully prior to the next HTTP execute. Your code should be appear in the following order:

        responseH = httpclient.execute(getHNMR);
        HttpEntity entityH = responseH.getEntity();
        HNMR = EntityUtils.toString(entityH);
    
        responseC = httpclient.execute(getCNMR);
        HttpEntity entityC = responseC.getEntity();
        CNMR = EntityUtils.toString(entityC);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to retrieve JSON data from an external text file using a
I am trying to retrieve the text data from an ePub file using Java.
I'm trying to retrieve this page using Apache HttpClient: http://quick-dish.tablespoon.com/ Unfortunately, when I try
I am trying to use a textreader to retrieve data from a text file
I get the following message back when trying to retrieve a file using TCPClient
I'm trying to retrieve link text from an HTML file. Each of the link
I am trying retrieve user name from the code through graph api, the below
I'm trying to retrieve product information from magento by calling its web service using
I am trying to retrieve particular data from a txt file and would like
I'm trying to retrieve data from a POST method, code as follows: -(void)postXMLFeed:(NSString *)XMLStrPost

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.