2016-02-22 115 views
0

我的代码无法读取属性文件。任何人都可以帮忙吗?它打印无法找到该文件。阅读Java中的属性文件

BufferedReader br = null; 
String strLine = ""; 
try { 
    br = new BufferedReader(new FileReader("C:/common-test/common-test/translationtest/messages_ja.property")); 
    while((strLine = br.readLine()) != null){ 
     System.out.println(strLine); 
    } 
} catch (FileNotFoundException e) { 
    System.err.println("Unable to find the file: fileName"); 
} catch (IOException e) { 
    System.err.println("Unable to read the file: fileName"); 
} 
+0

更改'/'到'\\',也逃脱他们 – Ramanlfc

+1

我强烈建议打印实际的异常,而不是自己的自定义输出。这会给你更多的信息(比如为什么它不工作)。 – Hypino

+1

你会得到什么例外?请使用此代码'catch(IOException e){e.printStackTrace(); }'并向我们显示错误消息 – Nayuki

回答

0

尝试使用此\\

"C:\\common-test\\common-test\\translationtest\\messages_ja.property" 

你一定要使用.property.properties