|
18 | 18 | */
|
19 | 19 | public class CreateErrorNums {
|
20 | 20 |
|
21 |
| - public static class ErrorNum { |
22 |
| - private String name; |
23 |
| - private Integer num; |
24 |
| - |
25 |
| - public ErrorNum(String name, Integer num) { |
26 |
| - this.name = name; |
27 |
| - this.num = num; |
28 |
| - } |
29 |
| - |
30 |
| - public String getName() { |
31 |
| - return name; |
32 |
| - } |
33 |
| - |
34 |
| - public Integer getNum() { |
35 |
| - return num; |
36 |
| - } |
37 |
| - |
38 |
| - @Override |
39 |
| - public String toString() { |
40 |
| - return "\tpublic static final int " + name + " = " + num + ";"; |
41 |
| - } |
42 |
| - |
43 |
| - } |
44 |
| - |
45 |
| - public static void main(String[] args) { |
46 |
| - |
47 |
| - if (args.length < 1) { |
48 |
| - System.out.println("Usage:"); |
49 |
| - System.out.println(""); |
50 |
| - System.out.println("CreateErrorNums <path and filename of arangodb errors.dat>"); |
51 |
| - System.out.println(""); |
52 |
| - System.out.println("Example"); |
53 |
| - System.out.println("CreateErrorNums ~/arangodb/lib/BasicsC/errors.dat"); |
54 |
| - System.exit(0); |
55 |
| - } |
56 |
| - |
57 |
| - String filename = args[0]; |
58 |
| - |
59 |
| - BufferedReader br = null; |
60 |
| - try { |
61 |
| - br = new BufferedReader(new FileReader(filename)); |
62 |
| - } catch (FileNotFoundException e) { |
63 |
| - System.out.println("File '" + filename + "' not found"); |
64 |
| - System.exit(0); |
65 |
| - } |
66 |
| - |
67 |
| - List<ErrorNum> errorNums = new ArrayList<ErrorNum>(); |
68 |
| - |
69 |
| - String line; |
70 |
| - try { |
71 |
| - while ((line = br.readLine()) != null) { |
72 |
| - // process the line. |
73 |
| - |
74 |
| - String[] part = line.split(","); |
75 |
| - if (part.length > 2) { |
76 |
| - Integer num = new Integer(part[1]); |
77 |
| - ErrorNum en = new ErrorNum(part[0], num); |
78 |
| - errorNums.add(en); |
79 |
| - } |
80 |
| - |
81 |
| - } |
82 |
| - } catch (IOException e1) { |
83 |
| - } |
84 |
| - |
85 |
| - try { |
86 |
| - br.close(); |
87 |
| - } catch (IOException e) { |
88 |
| - } |
89 |
| - |
90 |
| - try { |
91 |
| - String current = new java.io.File(".").getCanonicalPath(); |
92 |
| - System.out.println("Current dir: " + current); |
93 |
| - |
94 |
| - File file = new File("src/main/java/at/orz/arangodb/ErrorNums.java"); |
95 |
| - BufferedWriter output = new BufferedWriter(new FileWriter(file)); |
96 |
| - |
97 |
| - output.write("package com.arangodb;\r\n"); |
98 |
| - output.write("\r\n"); |
99 |
| - output.write("public class ErrorNums {\r\n"); |
100 |
| - output.write("\r\n"); |
101 |
| - |
102 |
| - for (ErrorNum en : errorNums) { |
103 |
| - output.write(en.toString() + "\r\n"); |
104 |
| - } |
105 |
| - |
106 |
| - output.write("\r\n"); |
107 |
| - output.write("}\r\n"); |
108 |
| - output.write("\r\n"); |
109 |
| - |
110 |
| - output.close(); |
111 |
| - } catch (IOException e) { |
112 |
| - e.printStackTrace(); |
113 |
| - } |
114 |
| - |
115 |
| - System.out.println("OK."); |
116 |
| - } |
| 21 | + public static class ErrorNum { |
| 22 | + private String name; |
| 23 | + private Integer num; |
| 24 | + |
| 25 | + public ErrorNum(String name, Integer num) { |
| 26 | + this.name = name; |
| 27 | + this.num = num; |
| 28 | + } |
| 29 | + |
| 30 | + public String getName() { |
| 31 | + return name; |
| 32 | + } |
| 33 | + |
| 34 | + public Integer getNum() { |
| 35 | + return num; |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public String toString() { |
| 40 | + return "\tpublic static final int " + name + " = " + num + ";"; |
| 41 | + } |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + public static void main(String[] args) { |
| 46 | + |
| 47 | + if (args.length < 1) { |
| 48 | + System.out.println("Usage:"); |
| 49 | + System.out.println(""); |
| 50 | + System.out.println("CreateErrorNums <path and filename of arangodb errors.dat>"); |
| 51 | + System.out.println(""); |
| 52 | + System.out.println("Example"); |
| 53 | + System.out.println("CreateErrorNums ~/arangodb/lib/BasicsC/errors.dat"); |
| 54 | + System.exit(0); |
| 55 | + } |
| 56 | + |
| 57 | + String filename = args[0]; |
| 58 | + |
| 59 | + BufferedReader br = null; |
| 60 | + try { |
| 61 | + br = new BufferedReader(new FileReader(filename)); |
| 62 | + } catch (FileNotFoundException e) { |
| 63 | + System.out.println("File '" + filename + "' not found"); |
| 64 | + System.exit(0); |
| 65 | + } |
| 66 | + |
| 67 | + List<ErrorNum> errorNums = new ArrayList<ErrorNum>(); |
| 68 | + |
| 69 | + String line; |
| 70 | + try { |
| 71 | + while ((line = br.readLine()) != null) { |
| 72 | + // process the line. |
| 73 | + |
| 74 | + String[] part = line.split(","); |
| 75 | + if (part.length > 2) { |
| 76 | + Integer num = new Integer(part[1]); |
| 77 | + ErrorNum en = new ErrorNum(part[0], num); |
| 78 | + errorNums.add(en); |
| 79 | + } |
| 80 | + |
| 81 | + } |
| 82 | + } catch (IOException e1) { |
| 83 | + } |
| 84 | + |
| 85 | + try { |
| 86 | + br.close(); |
| 87 | + } catch (IOException e) { |
| 88 | + } |
| 89 | + |
| 90 | + try { |
| 91 | + String current = new java.io.File(".").getCanonicalPath(); |
| 92 | + System.out.println("Current dir: " + current); |
| 93 | + |
| 94 | + File file = new File("src/main/java/com/arangodb/ErrorNums.java"); |
| 95 | + BufferedWriter output = new BufferedWriter(new FileWriter(file)); |
| 96 | + |
| 97 | + output.write("package com.arangodb;\r\n"); |
| 98 | + output.write("\r\n"); |
| 99 | + output.write("public class ErrorNums {\r\n"); |
| 100 | + output.write("\r\n"); |
| 101 | + |
| 102 | + for (ErrorNum en : errorNums) { |
| 103 | + output.write(en.toString()); |
| 104 | + output.write("\n"); |
| 105 | + } |
| 106 | + |
| 107 | + output.write("\r\n"); |
| 108 | + output.write("}\r\n"); |
| 109 | + output.write("\r\n"); |
| 110 | + |
| 111 | + output.close(); |
| 112 | + } catch (IOException e) { |
| 113 | + e.printStackTrace(); |
| 114 | + } |
| 115 | + |
| 116 | + System.out.println("OK."); |
| 117 | + } |
117 | 118 |
|
118 | 119 | }
|
0 commit comments