實際上,我需要替換源xml中的一些標記並將這些文件編寫爲新文件。在這裏我的代碼工作正常,但現在我無法打開輸出XML。在輸出XML中,我有一些泰米爾語單詞。這是文件不能打開的原因無法使用java將文件從一個xml寫入另一個xml
public class dxml {
public static StringBuffer sb = new StringBuffer() ;
public static void main(String [] args) throws Exception {
File xmlFile = new File("/home/dev702/Desktop/axl/Data Entry.xml");
BufferedReader br = new BufferedReader(
new FileReader("/home/dev702/Desktop/axl/Data Entry.xml"));
String line = null;
int linecount = 1;
FileWriter fw;
BufferedWriter bw = null;
fw = new FileWriter("/home/dev702/Desktop/axl/Data_Entry_OPT.xml") ;
bw = new BufferedWriter(fw);
while((line = br.readLine())!= null)
{
if(linecount > 2)
{
line = line.replaceAll("Data_x0020_Entry_x0020_Date",
"DataEntryDate");
//bw.write(line);
}
bw.write(line);
linecount++;
System.out.println(line);
}
bw.close();
fw.close();
}
}
你得到的錯誤是什麼? –
我沒有收到任何錯誤,但新文件沒有打開 – user3354849
您正在使用哪種編輯器? –