Getting Java.lang.SecurityException while prasing a XML file using SAX
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anand_Balasubramanian
Posted On:   Tuesday, May 8, 2001 04:10 PM

I am getting Java.lang.SecurityException: sealing violation while running a java program which prase a xml file using sax parser. How can I solve this problem? XML file is as follows. import java.io.*; import org.xml.sax.*; import javax.xml.parsers.SAXParserFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; public class Echo01 extends HandlerBase { Writer out; public Echo01() { SAXParserFactory factory = SAXParserFactory.newInstance(); try { out = new OutputStreamWriter (System.out, "UTF-8"); SAXParser saxParser = factory.newSAXParser(); saxParser.parse("c:   More>>

I am getting Java.lang.SecurityException: sealing violation while running a java program which prase a xml file using sax parser. How can I solve this problem?
XML file is as follows.

import java.io.*;

import org.xml.sax.*;

import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;

public class Echo01 extends HandlerBase {

Writer out;
public Echo01() {

SAXParserFactory factory = SAXParserFactory.newInstance();
try {

out = new OutputStreamWriter (System.out, "UTF-8");
SAXParser saxParser = factory.newSAXParser();
saxParser.parse("c:/anand/xml/slideSample01.xml", this);

} catch (Throwable t) {
t.printStackTrace ();
}
System.exit (0);
}

public void startDocument () throws SAXException {
emit (" <?xml version='1.0' encoding='UTF-8'?>");
nl();
}

public void endDocument () throws SAXException {
try {
nl();
out.flush ();
} catch (IOException e) {
throw new SAXException ("I/O error", e);
}
}

public void startElement (String name, AttributeList attrs) throws SAXException {
emit (" <"+name);
if (attrs != null) {
for (int i = 0; i < attrs.getLength (); i++) {
emit (" ");
emit (attrs.getName(i)+"=""+attrs.getValue (i)+""");
}
}
emit (">");
}

public void endElement (String name) throws SAXException {
emit (" </"+name+">");
}

public void characters (char buf [], int offset, int len) throws SAXException {
String s = new String(buf, offset, len);
emit (s);
}

private void emit (String s) throws SAXException {
try {
out.write (s);
out.flush ();
} catch (IOException e) {
throw new SAXException ("I/O error", e);
}
}

private void nl () throws SAXException {
String lineEnd = System.getProperty("line.separator");
try {
out.write (lineEnd);
} catch (IOException e) {
throw new SAXException ("I/O error", e);
}
}

public static void main (String args[]) {
Echo01 e = new Echo01();
}

}

   <<Less
About | Sitemap | Contact