关于Java,求助!
Object[] array = new Object[] {new String[] { "age", "income", "student", "credit_rating", "buys_computer" },
new String[] { "youth", "high", "no", "fair", "no" },
new String[] { "youth", "high", "no", "excellent", "no" },
这是部分代码,我想把 "age", "income", "student", "credit_rating", "buys_computer"
"youth", "high", "no", "fair", "no"
"youth", "high", "no", "excellent", "no"
放在一个txt文件中,在写代码把它们读入,而不是这样直接的,应该怎么办 --------------------编程问答-------------------- 使用IO流 读的操作就可以实现 --------------------编程问答-------------------- File file = new File("c:/text.txt");//文件的位置
FileReader read;
try {
read = new FileReader(file);
BufferedReader bufReader = new BufferedReader(read); //创建读取缓冲
while(bufReader.read()!=-1){//当读取结果不为-1时继续读取
System.out.println(bufReader.readLine());//将读出的一行输出
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
希望对你有帮助!!! --------------------编程问答-------------------- 与楼主有过一样的问题,同求解决
补充:Java , J2ME