Scanner in = new Scanner(new FileInputStream(file));
textArea.setText("");
repeat:
while(in.hasNextLine())
{
line = in.nextLine();
textArea.append(line);
textArea.append("\n");
textArea.repaint();
break repeat;
}在while循环内我使用了break语句跳出到while循环开始处,但是为什么程序运行后,只能显示txt文本中的第一句呢???
应该怎么写才能显示文本的全部呢???
textArea.setText("");
repeat:
while(in.hasNextLine())
{
line = in.nextLine();
textArea.append(line);
textArea.append("\n");
textArea.repaint();
break repeat;
}在while循环内我使用了break语句跳出到while循环开始处,但是为什么程序运行后,只能显示txt文本中的第一句呢???
应该怎么写才能显示文本的全部呢???
不用不就可以达到你的要求。
我是新手``多指教