File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
src/main/java/pl/koder95/eme/dfs Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 17
17
18
18
package pl .koder95 .eme .dfs ;
19
19
20
+ import java .io .BufferedWriter ;
20
21
import java .io .File ;
21
22
import java .io .IOException ;
23
+ import java .nio .file .Files ;
22
24
import java .util .ArrayList ;
23
25
import java .util .LinkedList ;
24
26
import java .util .List ;
@@ -106,6 +108,19 @@ public static Book load(Node book) {
106
108
public static List <Book > load (File xml ) throws IOException ,
107
109
ParserConfigurationException , SAXException {
108
110
LinkedList <Book > books = new LinkedList <>();
111
+ if (!xml .exists ()) {
112
+ try (BufferedWriter writer = Files .newBufferedWriter (xml .toPath ())) {
113
+ writer .write (
114
+ "<?xml version=\" 1.0\" encoding=\" utf-8\" standalone=\" no\" ?>\n " +
115
+ "<indices>\n " +
116
+ " <book name=\" Księga zaślubionych\" ></book>\n " +
117
+ " <book name=\" Księga zmarłych\" ></book>\n " +
118
+ " <book name=\" Księga ochrzczonych\" ></book>\n " +
119
+ " <book name=\" Księga bierzmowanych\" ></book>\n " +
120
+ "</indices>"
121
+ );
122
+ }
123
+ }
109
124
Document doc = XMLLoader .loadDOM (xml );
110
125
Element indices = doc .getDocumentElement ();
111
126
if (indices .getNodeName ().equalsIgnoreCase ("indices" )) {
You can’t perform that action at this time.
0 commit comments