-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSave.java
More file actions
39 lines (34 loc) · 1.08 KB
/
Save.java
File metadata and controls
39 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package Test;
import java.io.BufferedWriter;
import java.io.FileWriter;
/**
*
* @author asraf
*/
public class Save {
public static void main(String[] args) {
}
public static void write(Load data){
try{
// Creates a FileWriter
FileWriter fileName = new FileWriter("Data.txt");
// Creates a BufferedWriter
BufferedWriter bw = new BufferedWriter(fileName);
for (ReplyNode<ConfessionPost> node : data.tree){
bw.write(node.data.toString());
if(node.parent != null){
bw.write("\nParent ID="+node.parent.data.getID()+"\n");
}else{
bw.write("\nParent ID=None\n");
}
}
bw.close();
}catch(Exception e){
System.out.print("An error occured try again ");
}
}
}