-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelete.java
More file actions
73 lines (55 loc) · 1.86 KB
/
Delete.java
File metadata and controls
73 lines (55 loc) · 1.86 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.io.*;
import java.util.*;
class Delete extends Headertop
{
public static void del(String code)throws Exception
{
Scanner sc=new Scanner(new File("Institutions.dat"));
PrintWriter pr=new PrintWriter(new BufferedWriter(new FileWriter("temp.dat")));
String name,address,contact,category,hostel,fid,record,c,cid;
int flag=0;
clearcls();
View.readfile(code);
System.out.println("\n\n\n\n");
head("DELETE INSTITUTES");
System.out.println("--------------------------------------------------------------------------------------------------");
System.out.println("Enter name of Institute to be Deleted");
name=enterString();
while(sc.hasNextLine())
{
record=sc.nextLine();
Scanner sc1=new Scanner(record).useDelimiter(";");
c=sc1.next();
cid=sc1.next();
fid=sc1.next();
if(fid.equalsIgnoreCase(name)==false)
pr.println(record);
else
{
name=fid;
address=sc1.next();
contact=sc1.next();
category=sc1.next();
hostel=sc1.next();
System.out.println("Existing values are given below, the following record will be deleted");
System.out.println("--------------------------------------------------------------------------------------");
String leftAllignFormat="| %-9s| %-25s| %-25s| %-15s| %-15s| %-8s|%n";
System.out.format(leftAllignFormat,cid,name,address,contact,category,hostel);
System.out.println("--------------------------------------------------------------------------------------");
flag=1;
}
sc1.close();
}
sc.close();
pr.close();
if(flag==1)
System.out.println("Record Deleted");
else
System.out.println("Record could not be found");
File f=new File("Institutions.dat");
File f1=new File("temp.dat");
f.delete();
f1.renameTo(f);
callagain();
}
}