【发布时间】:2015-03-03 14:45:18
【问题描述】:
当我运行这个程序时,它意味着写入文本文件,文本文件与我的项目文件夹位于同一目录中。
try
{
Scanner inFile = new Scanner(new File ("details.txt"));
while(inFile.hasNext())
{
String line = inFile.nextLine(); //reads the line of text
Scanner del = new Scanner(line).useDelimiter("#"); //scanner class to delimit
String name = del.next();
String gender = del.next();
int age = del.nextInt();
double amount = del.nextDouble();
txaDisplay.append(name+"\t"+gender+"\t"+age+"\t"+amount+"\n");
del.close();
}
inFile.close();//end try
}
catch(FileNotFoundException f)
{
txaDisplay.append("File Not Found");
System.exit(0);}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new yest().setVisible(true);
}
});}
【问题讨论】: