• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem reading in XML files

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there
I am currently experiencing a problem whilst reading in xml files, which I am suspecting is down to this :-
The file that is being parsed is throwing parse exceptions as it is not well formed. On examination, the file is actually ok.
The file is ftp'd onto my server beforehand, so I think that my code is trying to parse the file while it is still be transferred! The xml files are quite large so they might take a few seconds to upload.
I've done a few things at the moment to try and combat this, like check the lastmodified time and the permissions on the file, but is there another REAL way that can be used to properly fix this?
Code snippet is here, manager is a SecurityManager and this class also implements ErrorHandler.

Al
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting problem. I am afraid there is no REAL way of doing this since java.io.File hides the remoteness of the entity being referred.
Another thing you could do is to separate the file reading logic from parsing logic. Instead of letting the parser pull the remote file, you can do the same before handling the file to the parser.
For instance, read the file ( using a stream? ) and save it to a local temp directory. Then handover the file (or the stream) to the parser.
IMO this approach will result in a clearner design.
Hope that helps.
 
Alex Ioannou
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thought about your possible solutions.
The stream or parser will never know when the file is ready to read, so there will be have to be some mickey mouse testing in whatever class is delegated the task of IO.
Another thing that I can think of is in the FTP process itself, perhaps ftp supports file locking, then the security manager can be used to detect whether a file is ready for processing or not?
Al
 
reply
    Bookmark Topic Watch Topic
  • New Topic