可能重复:
将节点附加到现有的 xml-Java
我有这个代码
private void nextActionPerformed(java.awt.event.ActionEvent evt) {
File myfile;
FileInputStream myInputStream;
InputStreamReader myInputStreamReader;
BufferedReader myBufferedReader;
String databasedir =
"C:\\Users\\himu\\Documents\\NetBeansProjects\\database\\src\\database\\databases\\";
try{
myfile = new File(databasedir+dbname.getText());
myInputStream = new FileInputStream(myfile);
myInputStreamReader = new InputStreamReader(myInputStream);
myBufferedReader = new BufferedReader(myInputStreamReader);
String xmlval =
"<database>"
+ "<db id =" +dbname.getText() +">"
+ " <dbfileloc>" +myfile
+ "</dbfileloc> "
+ "</db>"
+ "</database>";
}
catch(Exception e)
{
}
}
**我想在已创建的 dbrepoloc.xml 文件中的上一个 xmlval 条目之后附加字符串 xmlval,该文件具有此位置 C:\Users\himu\Documents\NetBeansProjects\database\src\database\dbrepoloc.xml 我是没有得到上面提到的地方的确切代码请帮助我