-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathHaveToken.java
More file actions
49 lines (43 loc) · 1.04 KB
/
HaveToken.java
File metadata and controls
49 lines (43 loc) · 1.04 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
package parse;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class HaveToken {
Token_List tk=null;
public HaveToken(){
getToken();
}
public void getToken() {
try {
Process pr=Runtime.getRuntime().exec("D:\\Python34\\python.exe token.py test.t");
BufferedReader in =new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line;
tk=new Token_List();
String []wrong=null;
pr.waitFor();
while((line=in.readLine())!=null){
wrong=line.split(":");
//equals()方法表示比较对象内容,==会比较对象的地址
if(wrong[0].equals("word")){
System.out.println(line);
tk=null;
break;
}
if(!wrong[1].equals("\"")){ //去掉字符串常量中的“ ”
tk.appendToken(new StringBuilder(line));
// System.out.println(line);
}
}
in.close();
} catch (Exception e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public Token_List getTokenList(){
Token_List tokenlist=null;
if(this.tk!=null){
tokenlist=this.tk;
}
return tokenlist;
}
}