Skip Navigation Links

Eric Bergman-Terrell's Blog

Previous Blog Entry Java Tip: Parsing an XML File with Embedded Spaces with SAX

November 23, 2008

If you pass a file path string as the first parameter to SAXParser.parse, the file path cannot contain any embedded spaces. Instead, create a FileInputStream object associated with the file path, and pass that object to SAXParser.parse:

// If the first argument to parse is a filename with embedded spaces, an exception will be thrown. The solution is to
// use a FileInputStream instead of a file path.
SAXParser saxParser = saxParserFactory.newSAXParser();
ImportDefaultHandler importDefaultHandler = new ImportDefaultHandler();

FileInputStream inputStream = new FileInputStream(filePath);
saxParser.parse(inputStream, importDefaultHandler);
Keywords: Java, XML, SAX, parsing, SAXParser, FileInputStream

Comment on this Blog Post
Previous Blog Entry Java Tip: How to read a file and automatically specify the correct encoding

Recent Posts

Posting Calendar

Title Date
Java Tip: Parsing an XML File with Embedded Spaces with SAX November 23, 2008
Java Tip: How to read a file and automatically specify the correct encoding November 15, 2008
Getting VMware Server 2.0 to Install and Run October 11, 2008
Upgraded to Windows XP Professional x64 Edition August 28, 2008
"Embed Custom GUIs in WPF" article published in Dr. Dobb's August 06, 2008
Firefox 3.0 + Flashblock = Bliss June 18, 2008
Help! My SanDisk Sansa e280 FM Radio Doesn't Work! April 09, 2008
<November 2008
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Blog Archive

Home Page   Shareware   C# .NET Tips   Download C# .NET Source Code   Browse C# .NET Source Code   C# .NET Open Source   On-Line Utilities   Blog   Contact