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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:07:16+00:00 2026-05-27T04:07:16+00:00

I am trying to access data from a raw data stream. Before accessing the

  • 0

I am trying to access data from a raw data stream. Before accessing the raw data stream, I must parse/remove any traces of xml. I do this by converting the raw stream to a string array and by iterating through each line to remove the xml.

I can parse/remove the xml from the string okay and I can recreate the data stream. The problem I have is reading through each line and storing each value (year, month, day, power)
The while loop fails with an out of bound exception on the line:
int year = bb.get(0);

My guess is that this is happening because the newResult string that’s created isn’t being read correctly through the readLine method. Instead of having a list of raw data, there’s only one line of raw data. According to the specifications, there should be 60 (and the length of decResult-1 is 60.

Here is the code below. Can anyone help me to figure out why the while loop isn’t iterating through each line? Thanks.

try {                   
   HttpRequestBase request = null;
   request = new HttpGet(urlString);
   consumer.sign(request);
   Log.v(TAG, "consumer.sign");
   HttpResponse response = client.execute(request);
   InputStream stream = (InputStream)response.getEntity().getContent();
   String result = convertStreamToString(stream);
   String[] decResult = result.split("<day raw=\"");
   String newResult = ""; 
   if(decResult.length > 1) {
      for(int i=1; i<decResult.length; i++) {
         decResult[i] = decResult[i].replaceAll("\"\\/>", "");
         Log.v(TAG, "DecResult = "+ (decResult[i]).toString());
         decResult[i] = decResult[i].replaceAll("</ted5000_mtu_days>","");
         Log.v("DayData", decResult[i].toString());
         newResult = newResult.concat((decResult[i].toString() + "\n"));
   }
} 

Log.v("DayData", "newResult = "+ newResult);
Log.v("DayData", "End NewResult");
BufferedReader reader = new BufferedReader(new StringReader(newResult));
String line = null;
while((line = reader.readLine()) != null) {
   Log.v("DayData", "****Entering while loop***");
   Log.v("DayData", "Line = " + line);
   String bytes = Base64.decode(line);
   Log.v("DayData", "Received bytes");
   ByteBuffer bb = ByteBuffer.wrap(bytes.getBytes());
   Log.v("DayData", "ByteBuffer.wrap");
   bb.order(ByteOrder.LITTLE_ENDIAN);
   int year = bb.get(0);
   int month = bb.get(1);
   int day = bb.get(2);
   int power = bb.getInt(3);
   Log.i("DayData", "Date: " +  month + "/" + day + "/" + year +  " Power: " + power);
  }     
  Log.v("DayData", "Exiting while loop");
  } catch (Exception e) {
     e.printStackTrace();
     Log.e("DayData", "Exception: " + e.toString());
     return false;
}
}
  • 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-27T04:07:16+00:00Added an answer on May 27, 2026 at 4:07 am

    You should use an XML parser that suits your needs. From the wikipedia page:

    Existing APIs for XML processing tend to fall into these categories:

    • Stream-oriented APIs accessible from a programming language, for example SAX and StAX.

    • Tree-traversal APIs accessible from a programming language, for example DOM.

    • XML data binding, which provides an automated translation between an XML document and
      programming-language objects.

    • Declarative transformation languages such as XSLT and XQuery.

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

Sidebar

Related Questions

I am trying to access certain pieces of data from an xml file, here
Hey there, I am trying to access raw data from iphone camera using AVCaptureSession.
I'm trying to transfer some data from Access to SQL Server 2000 (there are
I am trying to access information from an Oracle meta-data table from within a
I'm trying to pull in data from a remote SQL Server. I can access
I'm trying to access list data using SSRS 2008. I have created an XML
I am currently trying to access the data that was just inserted using: if($this->User->save($this->data))
I am trying to access the data from MS Access Database using C#. in
I'm trying to access data from two different databases inside a transactionscope. But while
I'm trying to save the data from a viewController. I'm doing this by using

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.