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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:38:05+00:00 2026-06-07T12:38:05+00:00

I am downloading a file from and ftp, saving it onto my local filesystem

  • 0

I am downloading a file from and ftp, saving it onto my local filesystem and then reading it with createXMLStreamReader. When I try and parse it I get this error:javax.xml.stream.XMLStreamException: ParseError at [row,col]:[124,316]. When I copy and paste it to another file manually everything works fine. I have tried copying the file using this, the file gets copied but I am still getting the same error. I do realize that this is caused because of binary characters before the <xml node but I am not sure on how to get rid of them.

I have no control over what is being copied from the ftp and I am using java 1.7

My code for retrieving the file:

client.connect("ftp.domain.com");
client.login("user", "password");

String filename = assetsPath + "/ftpExport.xml";
fos = new FileOutputStream(filename);
client.retrieveFile("/Export.xml", fos);

My code to create the StreamReader:

inputFactory = XMLInputFactory.newInstance();
File f = new File(Parser.class.getProtectionDomain().getCodeSource().getLocation().getPath());
assetsPath = f.toString()+"/../assets";
xmlReader = inputFactory.createXMLStreamReader(
    new FileReader(assetsPath + "/Export.xml"));
  • 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-07T12:38:08+00:00Added an answer on June 7, 2026 at 12:38 pm

    don’t use a FileReader for reading xml as this can corrupt the xml. use a FileInputStream.

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

Sidebar

Related Questions

I am downloading a file from an ftp server and saving it to the
I am using apache commons-net for downloading a file from an FTP server. That
So far i wrote a code to download a file from ftp server then
Before downloading a file from ftp server, I want to check it if exist
I used following code for downloading XML file from ftp to android phone memory
I am using a cURL request for downloading a CSV file from an FTP
I am downloading an xml file from ftp and using the following code to
I am downloading files from an FTP server. Some of the file names have
I need to upload a file using ftp or http. I checked downloading from
I am downloading a file from a website and I have the link. But

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.