-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteJavaAnotations.java
More file actions
110 lines (87 loc) · 1.77 KB
/
DeleteJavaAnotations.java
File metadata and controls
110 lines (87 loc) · 1.77 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class DeleteJavaAnotations {
public static void deleteAnotations(FileReader reader,FileWriter writer)
{
Boolean slash_star = false;
Boolean slash_slash = false;
Boolean quotation = false;
Character pre = null;
Character cur = null;
int flag = 0;
try{
while((flag=reader.read()) != -1){
pre = cur;
cur = (char) flag;
if(slash_star==false && slash_slash == false && cur =='"'){
quotation = true;
writer.write(flag);
continue;
}
if(quotation == true){
if(cur =='"'){
quotation = false;
}
writer.write(flag);
continue;
}
if(slash_slash==false &&cur == '*' && pre == '/'){
slash_star = true;
continue;
}
if( slash_star == true){
if(cur == '/' && pre == '*'){
slash_star = false;
}
continue;
}
if(cur == '/' && pre == '/'){
slash_slash = true;
continue;
}
if(slash_slash == true ){
if( cur=='\n'){
slash_slash = false;
}
continue;
}
if(cur!='/' ){
writer.write(flag);
}
else
{
continue;
}
}
}
catch(IOException e){
e.printStackTrace();
}
finally{
if(writer != null){
try{
writer.flush();
writer.close();
}
catch(IOException e){
e.printStackTrace();
}
}
if(reader != null){
try{
reader.close();
}
catch(IOException e){
e.printStackTrace();
}
}
}
}
public static void main(String[] args) throws IOException{
FileReader reader = new FileReader("CopyOfanagrams1.java");
FileWriter writer = new FileWriter("CopyOfanagrams1deleteanotations.java");
deleteAnotations(reader, writer);
}
//modified
}