forked from gaopu/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteBookInfoToFile.java
More file actions
30 lines (26 loc) · 799 Bytes
/
WriteBookInfoToFile.java
File metadata and controls
30 lines (26 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
public class WriteBookInfoToFile extends Thread {
private Element root;
private String fileAddress;
public WriteBookInfoToFile(Element root,String fileAddress) {
this.root = root;
this.fileAddress = fileAddress;
}
@Override
public void run() {
Writer fileWriter;
try {
fileWriter = new FileWriter(fileAddress);
XMLWriter xmlWriter = new XMLWriter(fileWriter);
xmlWriter.write(root);
xmlWriter.close();
System.out.println("[" + fileAddress + "]写入成功");
} catch (IOException e) {
e.printStackTrace();
}
}
}