Skip to content

Commit 48f8ceb

Browse files
committed
Add Data Saving v1.03
1 parent afd6b55 commit 48f8ceb

File tree

1 file changed

+94
-94
lines changed

1 file changed

+94
-94
lines changed

src/cc/xehoth/graphviz/config/Config.java

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -12,98 +12,98 @@
1212

1313
public class Config implements Serializable {
1414

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+
*/
109109
}

0 commit comments

Comments
 (0)