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.

Propertyfiles updaten

Empfohlene Antworten

Veröffentlicht

Hi,

ich speichere ein paar daten meiner applikation in propertyfiles ... wenn ich nun eine eigenschaft aendere und diese dann per store in die datei schreibe, werden alle anderen eintraege geloescht. :(

wie kann ich das verhindern?

danke

okay so in etwa sieht es bei einem BufferedWriter aus:


BufferedWriter bw = new BufferedWriter(new FileWriter("datei.txt", true));

wobei es auf das ", true" ankommt ...

ich vermute mal bei den meisten Schreibarten gibt es diese Möglichkeit.

Greets

also bei mir sieht das so aus:

      out = new BufferedOutputStream( new FileOutputStream( APPPROPERTIEFILE ) );

      ApplicationProperties.setProperty( key, value );

      ApplicationProperties.store( out, "title" );

      out.close();

und der 2te parameter vom outputstream waere size ... mit boolean hat das nix zu tun ... ;)

dann probier mal folgendes:


      out = new BufferedOutputStream( new FileOutputStream( APPPROPERTIEFILE , true) );

      ApplicationProperties.setProperty( key, value );

      ApplicationProperties.store( out, "title" );

      out.close();

FileOutputStream(String name, boolean append) :

append - if true, then bytes will be written to the end of the file rather than the beginning

Quelle: http://java.sun.com/products/jdk/1.2/docs/api/java/io/FileOutputStream.html#FileOutputStream(java.lang.String,%20boolean)

nee ... nich wirklich. nun passiert genau das, was ich vermutet hatte ... :D

das propertyfile sieht wie eine logdatei aus. :(

#title

#Mon Apr 14 12:58:56 CEST 2003

MaxCollectorDays=1

SaveCustomer=1

LookAndFeel=Plastik

#title

#Mon Apr 14 14:28:17 CEST 2003

LookAndFeel=Plastik

#title

#Mon Apr 14 14:28:17 CEST 2003

MaxCollectorDays=3

#title

#Mon Apr 14 14:28:17 CEST 2003

SaveCustomer=0

#title

#Mon Apr 14 14:28:20 CEST 2003

LookAndFeel=Plastik

#title

#Mon Apr 14 14:28:20 CEST 2003

MaxCollectorDays=3

#title

#Mon Apr 14 14:28:20 CEST 2003

SaveCustomer=1

yo das schaut natürlich so aus weil einfach angehängt wird.

dann kannst du das mit dem true knicken ;)

musst vllt ne andere write methode versuchen..

http://java.sun.com/products/jdk/1.2/docs/api/java/io/BufferedWriter.html

einfach mal gucken, musst nen schreiber haben der an nem bestimmten byte anfängt und auch wieder aufhört denke ich ..

vielleicht liege ich auch daneben mit meiner idee ...

naja ne andere idee wäre dass du weisst welche zeile getauscht werden soll (wenn denn ne zeile getauscht werden soll).

dann zählst du irgendwie so lang hoch bis du in der richtigen zeile angelangt bist und ersetzt sie...

lass die fantasie spielen ;)

hm, ok. ich war mal kreativ ... :D

einfach alle properties auslesen, key aendern und wieder speichern. so funtzt's. :cool:


in = new BufferedInputStream( new FileInputStream( APPPROPERTIEFILE ) );

ApplicationProperties.load( in );

in.close();

out = new BufferedOutputStream( new FileOutputStream( APPPROPERTIEFILE ) );

ApplicationProperties.setProperty( key, value );

ApplicationProperties.store( out, "title" );

out.close();

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.