我有一个这样的文本文件:
abc def jhi
klm nop qrs
tuv wxy zzz
我想要一个字符串数组,如:
String[] arr = {"abc def jhi","klm nop qrs","tuv wxy zzz"}
我试过了 :
try
{
FileInputStream fstream_school = new FileInputStream("text1.txt");
DataInputStream data_input = new DataInputStream(fstream_school);
BufferedReader buffer = new BufferedReader(new InputStreamReader(data_input));
String str_line;
while ((str_line = buffer.readLine()) != null)
{
str_line = str_line.trim();
if ((str_line.length()!=0))
{
String[] itemsSchool = str_line.split("\t");
}
}
}
catch (Exception e)
{
// Catch exception if any
System.err.println("Error: " + e.getMessage());
}
请任何人帮助我......所有答案将不胜感激......