Visa signatur
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan
Hej!
Håller på med ett system som ska öppna och läsa en XML-fil, funkar kanon om jag skapar testfilerna själv, men.. jag får ett knasigt fel för filer som jag skapar med Java, då får jag felet:
SAXParseException: Premature end of file.
Felet kastas från den fetmarkerade raden. Har ni någon aning, eller är det vid filskapandet det blir fel? Jag har inga problem att öppna filen i en texteditor.
File file = new File(fileAndpath);
if(file.exists()){
ModelOffer.addStatus("File exists!");
try {
FileInputStream fis = new FileInputStream(file);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(new XMLFilterImpl());
Document doc = null;
ok = true;
try{
doc = db.parse(fis);
}catch(SAXException e){
ModelOffer.err("File corrupt ("+file.canExecute()+") cause: "+e);
return false;
}
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan
Kanske Daniel Schneller's Blog: SAXParseException: -1:-1: Premature End Of File - Misleading error kan ge någon hint..
Copyright © 1999–2023 Geeks AB. Allt innehåll tillhör Geeks AB.
Citering är tillåten om källan anges.