📄 readwords.java
字号:
import java.io.*;
import java.util.*;
import javax.swing.*;
public class ReadWords
{
FileReader in;
BufferedReader inTwo;
int ok=-1;
String str="*****";
public ReadWords()
{
}
public void setLinkFile(File f)
{
try{
in=new FileReader(f);
inTwo=new BufferedReader(in);
ok=1;
}
catch(IOException e){}
}
public String[] getWords()
{
String a[]=new String[30];
if(ok==1)
{
String contentLine=null;
try
{
contentLine=inTwo.readLine();
}
catch(IOException ee)
{
JFrame jframe=new lastStep("NO WORDS");
System.out.println("error");
System.exit(0);
}
StringTokenizer fenxi=new StringTokenizer(contentLine," *");
int count=fenxi.countTokens();
a=new String[count];
int k=0;
while( fenxi.hasMoreElements())
{
a[k]=fenxi. nextToken();
k++;
}
}
else if(ok==-1)
{
int k=0;
while( k<a.length)
{
a[k]="No";
k++;
}
}
return a;
}
public String getSentence()
{
String contentLine=null;
if(ok==1)
{
try{
contentLine=inTwo.readLine();
}
catch(IOException ee){}
}
else if(ok==-1)
{
int k=0;
contentLine=null;
}
return contentLine;
}
public void closeRead()
{
try
{
in.close();
inTwo.close();
ok=-1;
}
catch(Exception exp){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -