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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:12:35+00:00 2026-05-25T00:12:35+00:00

I have to create an application that retrieves a xml file on the web,

  • 0

I have to create an application that retrieves a xml file on the web, and stores it on the SD card in a Blackberry phone. The xml file is updated by a cron job. So I want the application to download the new xml file if data has been added to this xml file.

For now I compare all the data files using this piece of code

public static boolean isSame( DataInputStream input1, DataInputStream input2 ) throws IOException {
    boolean error = false;
      try {
          byte[] buffer1 = new byte[1024];
          byte[] buffer2 = new byte[1024];
          try {
              int numRead1 = 0;
              int numRead2 = 0;
              while (true) {
                  numRead1 = input1.read(buffer1);
                  numRead2 = input2.read(buffer2);
                  if (numRead1 > -1) {
                      if (numRead2 != numRead1) return false;
                      // Otherwise same number of bytes read
                      if (!Arrays.equals(buffer1, buffer2)) return false;
                      // Otherwise same bytes read, so continue ...
                  } else {
                      // Nothing more in stream 1 ...
                      return numRead2 < 0;
                  }
              }
          } finally {
              input1.close();

          }
      } catch (IOException e) {
          error = true; // this error should be thrown, even if there is an error closing stream 2
          throw e;
      } catch (RuntimeException e) {
          error = true; // this error should be thrown, even if there is an error closing stream 2
          throw e;
      } finally {
          try {
              input2.close();
          } catch (IOException e) {
              if (!error) throw e;
          }
      }
}

It works perfectly, but takes a long time to run.

So is it possible to read the end of the file to see if changes were made, and if so, re-download it ?

  • 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-25T00:12:35+00:00Added an answer on May 25, 2026 at 12:12 am

    In case you don’t find a way to read the end of the file:
    maybe it is possible to create another “mini” file that contains the end that you want to read.
    So for example if you want to read the last X bytes, then create a new file and write the last X bytes in it. it goes without saying that this file containing the last X bytes needs to be created/updated every time that the XML file gets created/updated by the cron job.

    On the device, you store both The XML and the “mini” file.
    but now you activate your method above on streams to the “mini” files that are found on the server and on the device. If you find that they are not equal, you download both the XML file and also the mini file and override them on the device.

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

Sidebar

Related Questions

I have to create a user in a third party application that stores its
i have an Java J2ME application that does (at user request) create HttpConnections to
I have built a MS Access 2007 application that can create reports files in
I have a requirement to create a simple windows forms application that allows an
Can I create an application with Flex Builder Trial ( that I have just
I have a WPF application where I'd like to create a custom pop-up that
I need to create a plug-in that updates an application. Look, I have a
Say I have a page in my web application that lets a user update
I have a CoreData-based application that retrieves data about past events from an SQLite
I have an application that uses a service to create an ArrayList of custom

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.