Witam,
Mam taką strukturę projektu:
próbuję zmienić zawartość tego pliku z poziomu javy, nie usuwając reszty parametrów. Jak uzyskać ścieżkę do tego pliku? Próbowałem System.getProperty("user.dir") +//db.properties; ale to nie znajduję.
private void loadPropertiesDb(){
try{
FileInputStream in = new FileInputStream("db.properties");
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream("db.properties");
props.setProperty("javax.persistence.jdbc.user", tFUserDb.getText());
props.setProperty("javax.persistence.jdbc.password", PFDb.getText());
props.setProperty("javax.persistence.jdbc.url", tFUrlDb.getText());
props.store(out, null);
out.close();
}catch (Exception ex){
ex.printStackTrace();
}
}{{Image:Capture.PNG}}
javax.persistence.jdbc.driver=com.mysql.jdbc.Driver
javax.persistence.jdbc.url=jdbc:mysql://localhost:3306/mojabaza
javax.persistence.jdbc.user=marcin
javax.persistence.jdbc.password=marcin
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
hibernate.connection.useUnicode=true
hibernate.connection.characterEncoding=UTF-8
java.io.FileNotFoundException: db.properties (The system cannot find the file specified)