ERLEDIGT
NEIN
NEIN
ANTWORTEN
1
1
ZUGRIFFE
355
355
EMPFEHLEN
-
Hallo alle zusammen,
habe da ein kleines Problem mir dem Speichern von Properties. Ich möchte nehmlich gerne zu einem Schlüssel eine Zeitangabe Speichern in etwa so " 34:45, soweit kein Problem bis auf das vor einem Doppelpunkt ":" ein Backslash "\" in die Datei reingeschrieben wird das sieht dann so aus "D5 = 09\:00" .
Wie kann ich das verhindern ?
Ich hoffe es gibt dafür ein Lösung.
Gruß Willi
-
28.11.04 22:27 #2
- Registriert seit
- Jun 2002
- Ort
- Saarbrücken (Saarland)
- Beiträge
- 9.886
- Blog-Einträge
- 29
Hallo!
Leider kann man an diesem verhalten nichts ändern (zumindest nicht so ohne weiteres), da es sich um ein Standardverhalten der API handelt umd Spezielle Zeichen Plattformübergreifend darzustellen. Dazu wird eben hier in deinem Beispiel das : Zeichen mit einem \ Escaped.
Das ist aber nicht weiter tragisch, da Java beim Laden wieder eine Rückkonvertierung in das "ursprüungliche" Format vornimmt.
Beispiel:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
package de.tutorials; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; public class Test19 { public static void main(String[] args) { Properties props = new Properties(); SimpleDateFormat sdf = new SimpleDateFormat("HH:MM"); String str = sdf.format(new Date()); props.put("time", str); try { props.store(new FileOutputStream("c:/time.properties"), null); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } props = new Properties(); try { props.load(new FileInputStream("c:/time.properties")); System.out.println(props.get("time")); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } }
Gruß tomJava rocks!
How to become a good Java Programmer?
Does IT in Java and .Net
The only valid measurement of code quality: WTFs / minute
Blog
Xing
Twitter
Ähnliche Themen
-
HILFE!! Fehler beim Speichern
Von jay79 im Forum Vektor-ProgrammeAntworten: 3Letzter Beitrag: 21.04.07, 12:41 -
Fehler beim Speichern in der Datenbank
Von Zimtgruen im Forum PHPAntworten: 2Letzter Beitrag: 05.06.06, 17:31 -
Fehler beim Speichern
Von zioProduct im Forum .NET CaféAntworten: 3Letzter Beitrag: 25.08.05, 10:56 -
Fehler beim Speichern
Von Susi99 im Forum Flash PlattformAntworten: 17Letzter Beitrag: 03.11.04, 15:40 -
Fehler beim Speichern von Optionen im IE
Von THE REAL TOOLKIT im Forum Microsoft WindowsAntworten: 1Letzter Beitrag: 26.11.02, 11:19





Zitieren

Login





