2
현재 XML 파일을 포함하고있는 단일 jar 파일 만 있으면 XML 파일에 대한 응용 프로그램의 액세스 권한을 XML 파일과 같은 디렉토리에 저장할 수 있습니다. 어떻게해야합니까?XML 데이터베이스를 jar 파일에 포함하고 XML 데이터베이스에 액세스하는 방법은 무엇입니까?
private String getXmlPath() {
String url = "";
try {
String cp = "Data\\QuestionList.xml";
File f = new File(ClassLoader.getSystemResource("\\").toURI().getPath());
url += f.getPath() + "\\" + cp;
} catch (URISyntaxException ex) {
url="QuestionList.xml";
}
System.out.println(url);
return url;
}
public void classifyQuestionnaire(String path)
throws FileNotFoundException, XMLStreamException, JAXBException {
// Parse the data, filtering out the start elements
XMLInputFactory xmlif = XMLInputFactory.newInstance();
FileReader fr = null;
if (path == null) {
fr = new FileReader(getXmlPath());
} else {
fr = new FileReader(path);
}
XMLEventReader xmler = xmlif.createXMLEventReader(fr);
EventFilter filter = new EventFilter() {
@Override
public boolean accept(XMLEvent event) {
return event.isStartElement();
}
};