PDA

View Full Version : java Properties


texerasmo
07-04-2005, 13:14
import java.io.FileInputStream;
import java.util.Properties;

public class PropertiesTest {
public static void main(String[] args) throws Exception {
// set up new properties object
// from file "myProperties.txt"
FileInputStream propFile = new FileInputStream(
"Database.properties");
Properties p = new Properties(System.getProperties());
p.load(propFile);

// set the system properties
System.setProperties(p);
// display new properties
System.getProperties().list(System.out);
}
}

se provate questa classe vi restituisce tutte le proprieta del file e non come faccio a farmi restiutire solo quelle che ci sono scritte nel file?

tglman
07-04-2005, 14:53
Cioč tu vorresti stampare sullo stdout i dati contenuti nel file....

Ciao.

texerasmo
07-04-2005, 16:50
si

tglman
07-04-2005, 17:23
allora cosa ti serve la classe properties bata che leggi da FileImputStream e lo scrivi su stdout...
le specifice di FileImputStream eccole qui (http://java.sun.com/j2se/1.3/docs/api/java/io/FileInputStream.html)

Ciao..

texerasmo
07-04-2005, 17:28
ok tnks