我一直在使用的actionListener
从众多TextFields
文本传递到一个名为writetouser.txt
这工作得很好,虽然我已经注意到,这段文字是刚刚倾倒而不是格式的文本文件数组。为了这个应用程序的目的,我有必要搜索这个文本文件,并显示基于输入的值的值。我有一个文件从文本文件读取数据,并试图将数据转换为CSV
's,因此它可以作为数组读取。我想知道必须输入什么,而不是用户,为了从文件writetouser.txt
中取文本。将文本转换在文本文件转储到CSV和阵列
附录:
public void ReadUser()
{
try{
// Open the file
FileInputStream fstream = new FileInputStream("writetouser.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
//System.out.println (strLine);
String[] items = strLine.split(",");
String[][] usersArray = new String [10][2];
for (String item : items) {
System.out.println(item);
}
}
//Close the input stream
in.close();
}catch (Exception e){
//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
} }
这里是我试图分离的数据的一个例子。它输入到文本文件作为
inputUser = user + ", " + pass;
writetouser.WriteToUser(inputUser);
dburgess,2345
这将有很大的帮助,如果你能为我们提供一个你想读取数据的一个例子。 – Joe 2011-05-23 17:00:59
上面的附录显示了一个数据的例子,以及它将文章传递给文本文件 – 2011-05-23 17:22:36