Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

properties in classpath speichern

Empfohlene Antworten

Veröffentlicht

Hallo,

wenn ich mit dem folgenden Code eine properties-Datei schreibe, wird sie in der C:// gespeichert anstatt in der classpath wie ich dachte:


		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 ?

Servus,

erst mal gar nicht. Der Classpath kann ja alles mögliche sein. Es muss sich nicht um _ein_ Verzeichnis handeln.

Erklär doch mal, wo Du es speichern willst, vielleicht verstehe ich es nur falsch.

Schöne Grüße,

Peter

Ich habe eine Java-Projekt mit:

src

.^----- com.firma.model

.^----- com.firma.dao

.^----- test.com.firma.model

...........^------------------ MyModelTest.java

...........^------------------ mymodeltest.properties

.^----- test.com.firma.dao

...........^------------------ MyDAOTest.java

...........^------------------ mydaotest.properties

Es handelt sich um JUnit-Tests.

Also ich müchte eigentlich beim Testen die Datei mydaotest.properties bzw. mymodeltest.properties aus dem Test Datei MyDAOTest.Java bzw. MyModelTest.Java auslesen bzw. schreiben.

Das ist eigentlich mein Problem!!!

Servus,

lesen ist hier kein Problem. Über Class#getResourceAsStream oder Class#getResource kommst Du an ein Objekt, das im Classpath liegt.

Speichern kannst Du es dort aber meines Wissens so nicht.

Warum willst Du denn dort schreiben? Vielleicht gibt es einen anderen / besseren Ansatz.

Peter

Danke!

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.