我想使用一个文本文件并将每行放入一个classobject数组中。这是我的代码将字符串文本文件转换为对象数组
try {
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("Patient.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);
}
// Close the input stream
in.close();
} catch (Exception e) { // Catch exception if any
System.err.println("Error: " + e.getMessage());
}
我需要转换成一个数组对象这一点,这是我希望它看起来像
Patient1 p[] = new Patient1[5];
p[0] = 001, "John", 17, 100, 65, 110, 110, 110, 109, 111, 114, 113, "Swaying, Nausea";
p[1] = 002, "Sun Min", 18, 101, 70, 113, 113, 110, 119, 111, 114, 113, "None";
等。
我想要一只小马。尽管如此,你需要告诉我们你尝试过什么,然后提出具体的问题。 – 2012-02-01 03:45:41