XMLStreamException while trying to parse an xml file downloaded from a ftp

giamcuibap

New Member
I am downloading a file from and ftp, saving it onto my local filesystem and then reading it with \[code\]createXMLStreamReader\[/code\]. When I try and parse it I get this error:\[code\]javax.xml.stream.XMLStreamException: ParseError at [row,col]:[124,316]\[/code\]. 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 \[code\]<xml\[/code\] 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 \[code\]java 1.7\[/code\]My code for retrieving the file:\[code\]client.connect("ftp.domain.com");client.login("user", "password");String filename = assetsPath + "/ftpExport.xml";fos = new FileOutputStream(filename);client.retrieveFile("/Export.xml", fos);\[/code\]My code to create the StreamReader:\[code\]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"));\[/code\]
 
Back
Top