Mercurial > hg > Members > tatsuki > jungle-bench
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/oldTree/CreateXML.java @ 11:cc219065cea3
error fix
author | one |
---|---|
date | Tue, 25 Nov 2014 12:07:55 +0900 |
parents | 2af5af044947 |
children |
comparison
equal
deleted
inserted
replaced
10:2af5af044947 | 11:cc219065cea3 |
---|---|
13 try { | 13 try { |
14 File file = new File("./XML/test.xml"); | 14 File file = new File("./XML/test.xml"); |
15 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); | 15 PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); |
16 pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); | 16 pw.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); |
17 int nodeCount = put(pw, 0, "", 0); | 17 int nodeCount = put(pw, 0, "", 0); |
18 | |
19 pw.close(); | 18 pw.close(); |
20 System.out.println(nodeCount); | 19 System.out.println(nodeCount); |
21 } catch (IOException e) { | 20 } catch (IOException e) { |
22 System.out.println(e); | 21 System.out.println(e); |
23 } | 22 } |
25 | 24 |
26 public static int put(PrintWriter pw, int deep, String str, int nodeCount) { | 25 public static int put(PrintWriter pw, int deep, String str, int nodeCount) { |
27 nodeCount++; | 26 nodeCount++; |
28 pw.println(str + "<element id = \"" + deep + "\">"); | 27 pw.println(str + "<element id = \"" + deep + "\">"); |
29 String newStr = str + " "; | 28 String newStr = str + " "; |
29 System.out.println("deep = " + deep); | |
30 deep++; | 30 deep++; |
31 if (deep < 20) { | 31 if (deep < 17) { |
32 nodeCount = put(pw, deep, newStr, nodeCount); | 32 nodeCount = put(pw, deep, newStr, nodeCount); |
33 nodeCount = put(pw, deep, newStr, nodeCount); | 33 nodeCount = put(pw, deep, newStr, nodeCount); |
34 } | 34 } |
35 pw.println(str + "</element>"); | 35 pw.println(str + "</element>"); |
36 return nodeCount; | 36 return nodeCount; |