J'ai un fichier de propriétés qui contient des caractères UTF-8 (veuillez regarder l'exemple que j'ai collé ci-dessous).
#-------------------------------------------------------------------------------
# Resource strings for Root SIP
#-------------------------------------------------------------------------------
# @TRNSLATION-NOTES/*
# * Don't translate the information in META-DATA-SEGMENT
# */@TRNSLATION-NOTES
# @META-DATA-SEGMENT/*
# Resource file related information (metadata)
#---
root.label.hpcards=HP képeslapok
root.label.128.2=HP barkácsolás
root.label.weather=Idjárás
root.label.401.2=Tête à modeler
#---
# Locale Information
#---
resource.meta.lang=ar
# */@META-DATA-SEGMENT
#---
# Labels
#---
# @TRNSLATION-NOTES/* 2010-08-11: Following are added. To be translated.
# */@TRNSLATION-NOTES
root.label.getmore=
root.msg.apps=
root.msg.getmore= www.hpeprintcenter.com . .
# @TRNSLATION-NOTES/* 2010-08-11: Above are added. To be translated.
# */@TRNSLATION-NOTES
root.label.2.2=
root.label.35.2=MSNBC
root.label.43.2=PBS Kids
root.label.47.2= Yahoo!
# @TRNSLATION-NOTES/* 2010-08-11: Following are added. To be translated.
# */@TRNSLATION-NOTES
root.label.dreamworks=DreamWorks
root.label.hpcards= HP
root.label.128.2= HP
root.label.nickelodeon=Nickelodeon
root.label.quickforms=
root.label.recipes=
root.label.sudoku=
root.label.tabbloid=Tabbloid
root.label.usatoday=USA Today
root.label.weather=
#---
# Error Messages
#---
# @TRNSLATION-NOTES/* 1. The text before the first colon (i.e. Print Apps) is displayed as title in the screen
# */@TRNSLATION-NOTES
# @TRNSLATION-NOTES/* 2010-08-16: Following is to be translated.
# */@TRNSLATION-NOTES
root.msg.fault.project.perz=Print Apps: Apps . Apps Apps URL : www.hpeprintcenter.com
root.msg.fault.project.unexpected= : . .
Je dois éditer le contenu de ce fichier de propriété. Le processus d'édition se déroule avec succès, mais après l'édition du fichier de propriété, la sortie est affichée comme ci-dessous.
#UTF-8
#Fri Dec 09 15:17:55 IST 2011
root.label.nickelodeon=Nickelodeon
root.label.2.2=\u0642\u0633\u064A\u0645\u0627\u062A
root.label.sudoku=\u0633\u0648\u062F\u0648\u0643\u0648
\uFEFF\#-------------------------------------------------------------------------------=
root.label.401.2=T\u00EAte \u00E0 modeler
root.msg.apps=\u0627\u0644\u062A\u0637\u0628\u064A\u0642\u0627\u062A
root.label.35.2=MSNBC
root.label.43.2=PBS Kids
root.msg.fault.project.perz=Print Apps\: \u0644\u0645 \u064A\u062A\u0645 \u062A\u062B\u0628\u064A\u062A \u0623\u064A Apps \u0639\u0644\u0649 \u0627\u0644\u0637\u0627\u0628\u0639\u0629 \u0644\u062F\u064A\u0643. \u064A\u0645\u0643\u0646\u0643 \u062A\u062B\u0628\u064A\u062AApps \u0639\u0644\u0649 \u0627\u0644\u0637\u0627\u0628\u0639\u0629 \u0628\u0627\u0633\u062A\u062E\u062F\u0627\u0645 \u0645\u0648\u0642\u0639 Apps \u0639\u0644\u0649 \u0648\u064A\u0628 \u0641\u064A \u0639\u0646\u0648\u0627\u0646 URL \u0627\u0644\u062A\u0627\u0644\u064A \: www.hpeprintcenter.com
root.label.getmore=\u0627\u0644\u062D\u0635\u0648\u0644 \u0639\u0644\u0649 \u0627\u0644\u0645\u0632\u064A\u062F
root.label.tabbloid=Tabbloid
root.label.128.2=\u0627\u0644\u0623\u0639\u0645\u0627\u0644 \u0627\u0644\u064A\u062F\u0648\u064A\u0629 \u0641\u064A HP
root.label.47.2=\u0645\u0648\u062C\u0632 Yahoo\!
root.label.86.3=MARMITON-1
root.label.hpcards=\u0627\u0644\u0628\u0637\u0627\u0642\u0627\u062A \u0641\u064A HP
root.label.weather=\u062D\u0627\u0644\u0629 \u0627\u0644\u0637\u0642\u0633
root.msg.fault.project.unexpected=\u062A\u0637\u0628\u064A\u0642\u0627\u062A \u0627\u0644\u0637\u0628\u0627\u0639\u0629\: \u063A\u064A\u0631 \u0645\u062A\u0648\u0641\u0631\u0629 \u0645\u0624\u0642\u062A\u064B\u0627. \u0627\u0644\u0631\u062C\u0627\u0621 \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629 \u0645\u0631\u0629 \u0623\u062E\u0631\u0649 \u0644\u0627\u062D\u0642\u064B\u0627.
root.label.dreamworks=DreamWorks
resource.meta.lang=ar
root.label.quickforms=\u0627\u0633\u062A\u0645\u0627\u0631\u0627\u062A \u0633\u0631\u064A\u0639\u0629
root.label.recipes=\u0648\u0635\u0641\u0627\u062A \u0627\u0644\u0637\u0639\u0627\u0645
root.msg.getmore=\u0627\u0644\u0631\u062C\u0627\u0621 \u0632\u064A\u0627\u0631\u0629 \u0627\u0644\u0645\u0648\u0642\u0639 www.hpeprintcenter.com \u0644\u0645\u0639\u0631\u0641\u0629 \u0627\u0644\u0645\u0632\u064A\u062F \u062D\u0648\u0644 \u0627\u0644\u062A\u0637\u0628\u064A\u0642\u0627\u062A \u0648\u0625\u062F\u0627\u0631\u0629 \u0627\u0644\u062A\u0637\u0628\u064A\u0642\u0627\u062A \u0639\u0644\u0649 \u0647\u0630\u0647 \u0627\u0644\u0637\u0627\u0628\u0639\u0629. \u064A\u062E\u062A\u0644\u0641 \u062A\u0648\u0641\u0631 \u0627\u0644\u062A\u0637\u0628\u064A\u0642 \u062D\u0633\u0628 \u0627\u0644\u0628\u0644\u062F \u0648\u0627\u0644\u0644\u063A\u0629.
root.label.usatoday=USA Today
Voici le code que j'ai utilisé, pour lire un fichier propre à partir d'une localisation spécifique et y écrire le contenu.
private static void saveFile(String filePath, String propertyStr, String appName) throws IOException {
BufferedReader fis = new BufferedReader(new InputStreamReader(new FileInputStream(filePath),"UTF-8"));
Properties p = new Properties();
p.load(fis);
fis.close();
p.setProperty(propertyStr, appName);
p.store(new FileOutputStream(filePath), "UTF-8");
}