-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile.java
More file actions
48 lines (36 loc) · 1.38 KB
/
File.java
File metadata and controls
48 lines (36 loc) · 1.38 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
40
41
42
43
44
45
46
47
48
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class File {
void DocSaver(String name , int age , int id){
try(BufferedWriter writer = new BufferedWriter(new FileWriter("E:\\txt\\AP.txt" , true))){
writer.write("Doctor: " + name + " age: " + age +" id: " + id + " added" + "\n");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
void DocDelete(int id){
JDBCDemo j = new JDBCDemo();
try(BufferedWriter writer = new BufferedWriter(new FileWriter("E:\\txt\\AP.txt" , true))){
for(Doctor d : j.getAllDoctors()){
if(d.DocId == id){
writer.write("Doctor: " + d.name + " age: " + d.age +" id: " + id + " Deleted" + "\n");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
void UpdateDoc(int id){
JDBCDemo j = new JDBCDemo();
try(BufferedWriter writer = new BufferedWriter(new FileWriter("E:\\txt\\AP.txt" , true))){
for(Doctor d : j.getAllDoctors()){
if(d.DocId == id){
writer.write("Doctor with ID: " + d.DocId + " Renamed to --> " + d.name + "\n");
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}