<pre id=\"best-answer-content\" class=\"reply-text mb10\">JavaHotKeyChecker.java:
=======================
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class JavaHotKeyChecker {
public static void main(String[] args) throws IOException {
boolean yon = doCheck(\"class\");
if(yon) {
System.out.println(\"yes\");
} else {
System.out.println(\"no\");
}
}
private static boolean doCheck(String input) throws IOException {
boolean isHotKey = false;
File file = new File(\"D:/javahotkey.txt\");
String content = \"\";
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String temp;
while (null != (temp = br.readLine())) {
content= temp;
}
String[] keys = content.split(\",\");
ListString keyList = new ArrayListString();
for (String key : keys) {
keyList.add(key.trim());
}
isHotKey = keyList.contains(input);
return isHotKey;
}
}
javahotkey.txt:
=================
public,static,void,class,interface,final,finally,catch,try |