[英]Java Inventory - How to read a file using FileInputStream?
[英]How can I read properties file through FileInputStream in java (ubuntu)
public static final String propFile =".//src//config//config.properties";
try {
inputStream = new FileInputStream(propFile);
prop.load(inputStream);
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup(prop.getProperty("jndi.name"));
conn = ds.getConnection();
} catch (SQLException e1) {
e1.printStackTrace();
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
我無法從屬性文件中讀取。 它說沒有這樣的目錄,但我在確切的位置有文件。
嘗試將propFile
變量設置為系統中'config.properties'
文件的絕對路徑。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.