文件的读取
写了一个读取文件的小程序 虽然程序编译没错 可运行结果总是不能有预期效果
读不到文件路径 也读不出文件内容
请大家帮我查查 出出主意 谢过!
代码如下:
public static void getAppInfoFromFile() {
try {
File path = new File(".\\AppInfo\\1.txt");
System.out.println(path.getPath().toString());
FileReader fw = new FileReader(path);
BufferedReader in = new BufferedReader(fw);
String temp = null;
String line = in.readLine();
boolean cont = true;
while (cont) {
if (line == null) {
cont = false;
}
else {
temp += line;
line = in.readLine();
}
System.out.println(temp);
}
in.close();
}
catch (IOException e) {
System.out.println("error!");
}