[encodage]String en UTF8 et combobox
Bonjour
voila je dois lire un fichier encoder en utf8. (différent langue européenne dans ce fichier ). J'ai un fonction qui lie ce fichier et qui renvoie une arraylist de String.
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
| private ArrayList<String> SearchAuthority(Object selectedItem) {
BufferedReader reader = null;
ArrayList<String> list = new ArrayList<String>();
try {
File fs = new File("C:\\Documents and Settings\\adamre\\My Documents\\NetBeansProjects\\EFormMockUp\\src\\eu\\europa\\ec\\eforms\\informationexchange\\v0\\gui\\InformationExchangeACKFormRequestedAuthority.properties");
reader = new BufferedReader(new InputStreamReader(new FileInputStream(fs), "UTF8"));
String line;
int i = 0;
while ((line = reader.readLine()) != null) {
if (line.substring(0, 2).equals(selectedItem.toString())) {
String essai = new String(line.substring(3).getBytes(), "UTF8");
byte[] essai2 = line.substring(3).getBytes("UTF-8");
System.out.println(essai2);
list.add(essai);
System.out.println("TROUVE");
}
i++;
}
} catch (FileNotFoundException ex) {
Logger.getLogger(InformationExchangeACKForm.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(InformationExchangeACKForm.class.getName()).log(Level.SEVERE, null, ex);
} finally {
try {
reader.close();
} catch (IOException ex) {
Logger.getLogger(InformationExchangeACKForm.class.getName()).log(Level.SEVERE, null, ex);
}
}
return list;
} |
ensuite j'ai fait donc cela
Code:
1 2 3 4 5 6 7 8 9 10 11
| ArrayList<String> requestedAuthority = SearchAuthority(comboBoxMemberState.getSelectedItem().toString());
comboBoxRequestedAuthority.removeAllItems();
for(String Authority: requestedAuthority){
try {
System.out.println(Authority);
comboBoxRequestedAuthority.addItem(new String(Authority.getBytes(), "UTF8"));
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(InformationExchangeACKForm.class.getName()).log(Level.SEVERE, null, ex);
}
} |
Dans ma combobox il y a toujours des caractères non reconnu j'ai essayé plein de truc et je m'y perd un peu. C'est donc un probleme encodage des string.
Est ce que quelqu'un peux m'aider.