|
12 | 12 |
|
13 | 13 | public class Config implements Serializable { |
14 | 14 |
|
15 | | - /** |
16 | | - * |
17 | | - */ |
18 | | - private static final long serialVersionUID = 1L; |
19 | | - |
20 | | - private boolean isAutoPainting = false; |
21 | | - |
22 | | - private String content = null; |
23 | | - |
24 | | - private boolean isDirected = false; |
25 | | - |
26 | | - private boolean hasWeight = false; |
27 | | - |
28 | | - private boolean saveLastData = true; |
29 | | - |
30 | | - public boolean isAutoPainting() { |
31 | | - return isAutoPainting; |
32 | | - } |
33 | | - |
34 | | - public void setAutoPainting(boolean isAutoPainting) { |
35 | | - this.isAutoPainting = isAutoPainting; |
36 | | - } |
37 | | - |
38 | | - public String getContent() { |
39 | | - return content; |
40 | | - } |
41 | | - |
42 | | - public void setContent(String content) { |
43 | | - this.content = content; |
44 | | - } |
45 | | - |
46 | | - public boolean isDirected() { |
47 | | - return isDirected; |
48 | | - } |
49 | | - |
50 | | - public void setDirected(boolean isDirected) { |
51 | | - this.isDirected = isDirected; |
52 | | - } |
53 | | - |
54 | | - public boolean isHasWeight() { |
55 | | - return hasWeight; |
56 | | - } |
57 | | - |
58 | | - public void setHasWeight(boolean hasWeight) { |
59 | | - this.hasWeight = hasWeight; |
60 | | - } |
61 | | - |
62 | | - public boolean isSaveLastData() { |
63 | | - return saveLastData; |
64 | | - } |
65 | | - |
66 | | - public void setSaveLastData(boolean saveLastData) { |
67 | | - this.saveLastData = saveLastData; |
68 | | - } |
69 | | - |
70 | | - public static long getSerialversionuid() { |
71 | | - return serialVersionUID; |
72 | | - } |
73 | | - |
74 | | - public static Config getData() throws FileNotFoundException, IOException, ClassNotFoundException { |
75 | | - ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.dat")); |
76 | | - Config config = (Config) ois.readObject(); |
77 | | - ois.close(); |
78 | | - ois = null; |
79 | | - BufferedReader br = new BufferedReader(new FileReader("config")); |
80 | | - String s = br.readLine(); |
81 | | - if (s.trim().endsWith("true")) { |
82 | | - config.isAutoPainting = true; |
83 | | - } else { |
84 | | - config.isAutoPainting = false; |
85 | | - } |
86 | | - s = br.readLine(); |
87 | | - if (s.trim().endsWith("true")) { |
88 | | - config.saveLastData = true; |
89 | | - } else { |
90 | | - config.saveLastData = false; |
91 | | - } |
92 | | - br.close(); |
93 | | - br = null; |
94 | | - return config; |
95 | | - } |
96 | | - |
97 | | - public static void saveData(Config config) throws FileNotFoundException, IOException { |
98 | | - ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data.dat")); |
99 | | - oos.writeObject(config); |
100 | | - oos.flush(); |
101 | | - oos.close(); |
102 | | - oos = null; |
103 | | - } |
104 | | - |
105 | | - /* |
106 | | - * public static void main(String[] args) { try { saveData(new Config()); } |
107 | | - * catch (IOException e) { e.printStackTrace(); } } |
108 | | - */ |
| 15 | + /** |
| 16 | + * |
| 17 | + */ |
| 18 | + private static final long serialVersionUID = 1L; |
| 19 | + |
| 20 | + private boolean isAutoPainting = false; |
| 21 | + |
| 22 | + private String content = null; |
| 23 | + |
| 24 | + private boolean isDirected = false; |
| 25 | + |
| 26 | + private boolean hasWeight = false; |
| 27 | + |
| 28 | + private boolean saveLastData = true; |
| 29 | + |
| 30 | + public boolean isAutoPainting() { |
| 31 | + return isAutoPainting; |
| 32 | + } |
| 33 | + |
| 34 | + public void setAutoPainting(boolean isAutoPainting) { |
| 35 | + this.isAutoPainting = isAutoPainting; |
| 36 | + } |
| 37 | + |
| 38 | + public String getContent() { |
| 39 | + return content; |
| 40 | + } |
| 41 | + |
| 42 | + public void setContent(String content) { |
| 43 | + this.content = content; |
| 44 | + } |
| 45 | + |
| 46 | + public boolean isDirected() { |
| 47 | + return isDirected; |
| 48 | + } |
| 49 | + |
| 50 | + public void setDirected(boolean isDirected) { |
| 51 | + this.isDirected = isDirected; |
| 52 | + } |
| 53 | + |
| 54 | + public boolean isHasWeight() { |
| 55 | + return hasWeight; |
| 56 | + } |
| 57 | + |
| 58 | + public void setHasWeight(boolean hasWeight) { |
| 59 | + this.hasWeight = hasWeight; |
| 60 | + } |
| 61 | + |
| 62 | + public boolean isSaveLastData() { |
| 63 | + return saveLastData; |
| 64 | + } |
| 65 | + |
| 66 | + public void setSaveLastData(boolean saveLastData) { |
| 67 | + this.saveLastData = saveLastData; |
| 68 | + } |
| 69 | + |
| 70 | + public static long getSerialversionuid() { |
| 71 | + return serialVersionUID; |
| 72 | + } |
| 73 | + |
| 74 | + public static Config getData() throws FileNotFoundException, IOException, ClassNotFoundException { |
| 75 | + ObjectInputStream ois = new ObjectInputStream(new FileInputStream("data.dat")); |
| 76 | + Config config = (Config) ois.readObject(); |
| 77 | + ois.close(); |
| 78 | + ois = null; |
| 79 | + BufferedReader br = new BufferedReader(new FileReader("config")); |
| 80 | + String s = br.readLine(); |
| 81 | + if (s.trim().endsWith("true")) { |
| 82 | + config.isAutoPainting = true; |
| 83 | + } else { |
| 84 | + config.isAutoPainting = false; |
| 85 | + } |
| 86 | + s = br.readLine(); |
| 87 | + if (s.trim().endsWith("true")) { |
| 88 | + config.saveLastData = true; |
| 89 | + } else { |
| 90 | + config.saveLastData = false; |
| 91 | + } |
| 92 | + br.close(); |
| 93 | + br = null; |
| 94 | + return config; |
| 95 | + } |
| 96 | + |
| 97 | + public static void saveData(Config config) throws FileNotFoundException, IOException { |
| 98 | + ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data.dat")); |
| 99 | + oos.writeObject(config); |
| 100 | + oos.flush(); |
| 101 | + oos.close(); |
| 102 | + oos = null; |
| 103 | + } |
| 104 | + |
| 105 | + /* |
| 106 | + * public static void main(String[] args) { try { saveData(new Config()); } |
| 107 | + * catch (IOException e) { e.printStackTrace(); } } |
| 108 | + */ |
109 | 109 | } |
0 commit comments