Announcement

Collapse
No announcement yet.

properties in classpath speichern

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • properties in classpath speichern

    Hallo,
    wenn ich mit dem folgenden Code eine properties-Datei schreibe, wird sie in der C:// gespeichert anstatt in der classpath wie ich dachte:
    Code:
    		Properties properties = new Properties();
    		properties.setProperty("a", "1");
    		properties.setProperty("b", "2");
    		
    		try{
    			Writer out = new FileWriter("niko.properties");
    			properties.store(out, "ddd");
    			out.close();
    Wie kann man die properties-Datei direckt in dem classpath speichern ?

  • #2
    Code:
    Properties mymodeltestprops = new Properties();
    InputStream propis = getClass().getClassLoader().getResourceAsStream("test/com/firma/model/mymodeltest.properties");
    if (propis != null) {
       mymodeltestprops.load(propis);
    }

    Comment


    • #3
      hallo Don_Pazo,
      ich verstehe deine Frage nicht ganz. Wenn du eine Propery-Datei an bestimmter Stelle speichern möchtest, dann mache so was:
      // z.B.
      // path = C://myoerdner/lala/
      //name = myproperties.properties
      File file = new File(path,name);
      FileWriter fw = new FileWriter(file);
      fw.flush();

      Comment

      Working...
      X