-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeywordJavaProgram.java
More file actions
46 lines (37 loc) · 1.62 KB
/
KeywordJavaProgram.java
File metadata and controls
46 lines (37 loc) · 1.62 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
import java.io.BufferedReader;
import java.io.FileReader;
import java.lang.reflect.Array;
import java.util.*;
/**
* Created with IntelliJ IDEA.
* User: sujit
* Date: 7/22/13
* Time: 3:50 PM
* To change this template use File | Settings | File Templates.
*/
public class KeywordJavaProgram {
static List key;
static String[] keyWordStringArray = {"abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new,package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","try","void","volatile","while"};
public static void main(String ar[]){
List<String> keyWord = Arrays.asList(keyWordStringArray);
Set<String> myKeyword = new HashSet<String>();
try {
String sReadLine = null;
BufferedReader br=new BufferedReader(new FileReader("d:\\MyFirstProgram.txt"));
while ((sReadLine=br.readLine())!=null) {
String[] tokonizePart = sReadLine.split("\\s");
for (String tokonizePartInsideFor : tokonizePart ){
if(keyWord.contains(tokonizePartInsideFor)){
myKeyword.add(tokonizePartInsideFor);
}
}
}
for(String my : myKeyword){
System.out.println(my +" is a key word");
}
br.close();
}
catch (Exception e){
}
}
}