[求助]偶写了个程序,但实现不了预期的结果
import javax.swing.*;import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class a extends JFrame
{
JTextArea box=new JTextArea(100,100);
public a()
{
super("read");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(600,300);
JScrollPane pane=new JScrollPane(box);
getContentPane().add(pane);
try {
//File f=new File(".txt");
FileReader file = new
FileReader("123.txt");
BufferedReader buff = new
BufferedReader(file);
//boolean eof = false;
StringBuffer buf=new StringBuffer();
/* while (!eof) {
String line = buff.readLine();
if (line == null)
eof = true;
else
buf.append(line+"\n");
}*/
String s=null;
if(buff!=null)
{
while((s=buff.readLine())!=null)
{
if(s.startsWith("**"));
//break;
buf.append("\n"+s);
if(s.startsWith("endend"))
{box.setText(buf.toString());
buff.close();}
}
}
} catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
show();
}
public static void main(String args[])
{
new a();
}
}
这个程序的目的是一次只读出一个题目,但是实现不了?各位高手给个意见,谢谢!
搜索更多相关的解决方案:
结果
----------------解决方案--------------------------------------------------------
这要看你的题目内容是什么啊,还有,你那个while没有跑出啊
----------------解决方案--------------------------------------------------------
你想问的是什么` 都不表达清楚`
----------------解决方案--------------------------------------------------------
1.Which interface does java.util.Hashable implement?
A. java.util.Map
B. java.util.List
C. java.util.Hashable
D. java.util.Collection
** Given:
(1). public class X {
(2). public object m () {
(3). object o = new Float (3.14F);
(4). object [] oa = new object [1];
(5). oa[0]= o;
(6). o = null;
(7). oa[0] = null;
(8).return o;
(9). }
(10). }
2.When is the float object created in line 3, eligible for garbage collection?
A. Just after line 5
B. Just after line 6
C. Just after line 7
D. Just after line 8(that is, as the method returns)
就好像这样的题目,一次只能读出一个
----------------解决方案--------------------------------------------------------
不同的题目有不同的实现方法吗?
----------------解决方案--------------------------------------------------------