public static void method_1()throws IOException
{
BufferedReader bufr = new BufferedReader(new FileReader("info.txt"));
String line = null;
Properties prop = new Properties();
while((line=bufr.readLine())!=null)
{
String[] arr = line.split("=");
System.out.println(arr[0]+"....."+arr[1]);
//prop.setProperty(arr[0],arr[1]);
}
bufr.close();
//System.out.println(prop);
}
定义一个method_1方法并在主函数内调用,在当前目录下也有info.txt文件,eclipse错误提示如下:
Exception in thread "main" java.io.FileNotFoundException: info.txt (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at java.io.FileReader.<init>(FileReader.java:58)
at day20.PropertiesDemo.method_1(PropertiesDemo.java:63)
at day20.PropertiesDemo.main(PropertiesDemo.java:27)
|
|