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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:17:13+00:00 2026-06-07T04:17:13+00:00

I have an XML file located in the assets folder. The XML file is

  • 0

I have an XML file located in the assets folder. The XML file is parsed to Object without issues (so that means the XML is 100% correct).

Now what I’m doing is I copy the XML file from the assets folder to the Internal Storage. When I try to open the copied XML file from the internal memory I always get an exception.

org.jdom.input.JDOMParseException: Error on line 660: At line 660, column 8: not well-formed (invalid token)

When calling this line:

Document doc = (Document) builder.build(xmlStream); (Where xmlStream is InputStream argument)

The file seems to be copied just fine, because I took the xmlStream-argument, converted it to String, and printed it to the screen, and it looks fine. They key here is that the exception always says that the last position of the file is wrong. So the last char of the closing tag at the buttom of the file is ‘>’ located in line 660 col 8.

The Copy operation

public  class  InternalMemory {
  private static Context mContext;
  public  static String INTERNAL_PATH;
  static {
    mContext = App.getContext();
    INTERNAL_PATH = mContext.getApplicationContext().getFilesDir().toString();
  }
  public static void SaveStream(InputStream is,String folder,String fileName) {
    String path = INTERNAL_PATH + "/"+folder+"/";
    File file = new File(path);
    file.mkdirs();
    path += fileName;
    OutputStream os;
    try {
      os = new BufferedOutputStream(new FileOutputStream(path,true));
      write(is,os);
      os.flush();
      os.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  private static void write(InputStream in, OutputStream out) throws IOException {
    byte[] buffer = new byte[1024];
    int read;
    while((read = in.read(buffer)) != -1){
      out.write(buffer, 0, read);
    }
  }
}
  • 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-07T04:17:15+00:00Added an answer on June 7, 2026 at 4:17 am

    Ok, like always.. didn’t notice i’m appending the file

    os = new BufferedOutputStream(new FileOutputStream(path,true));

    should be
    os = new BufferedOutputStream(new FileOutputStream(path,false));

    thanks all

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

Sidebar

Related Questions

I have parsed XML file into objects, in which each object has a 1:1
I have xml file that after my application installation will located in the installation
I have a WCF service library that reads a xml file that's located in
I have a unit test that needs to work with XML file located in
I do have a xml file located at : http://api.wunderground.com/api/adaebe40743a9ca6/geolookup/conditions/forecast/q/India/Pilani.xml Now i want to
I have an XML file that looks like <?xml version='1.0' encoding='UTF-8'?> <root> <node name=foo1
I have an XML file format that contains a structure of questions: <question id=q101>
I have student.xml file and am parsing this file using SAX Parser and now
I have two XML files located in res/xml/. One file is a normal XML
We have a large amount of apps. They all have a build.xml file located

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.