I'm exporting a SQL table into a txt using java. All works fine except a minus problem which is the accent mark on some letter. In particular I have problem with the 'è' because in my txt file is transmuted into 'è'. I don't know why, but if i try to export the record of my table that contains that field (so a single record writing) there's no issues; If i try to export the whole table (thousands of record), it gives me this problem.
I've already tried the replace method that the String class offers, but same result. I've also tried to use che escape character in unicode, but still the same problem. Any hints?
EDIT here's my code:
if(array_query.equals(versamenti_tasi)) {
File myOutputDir = new File("C:\\comuni\\prova\\009_001_Versamenti");
if(!myOutputDir.exists())
myOutputDir.mkdir(); //Returns a boolean if you want to check it was successful.
PrintStream o = new PrintStream(myOutputDir + "\\" + array_query[x].substring(26) + ".txt");
System.setOut(o);
while (rs.next()) {
out = "";
final_index = 0;
for(int i =1; i <= rsmd.getColumnCount(); i++) {
if(rs.getString(i) == null) {
final_index += rsmd.getColumnDisplaySize(i);
out += "" + str_valore;
out = out.substring(0, final_index);
}else{
final_index += rsmd.getColumnDisplaySize(i);
out += rs.getString(i).trim() + str_valore;
out = out.substring(0, final_index);
}
}
System.out.println(out);
}
briefily, the writing part is in the loop; str_valore is an empty string of 250 char, that's because I need to take the field's original size of my db; rs is my resultset and rsmd is the metadata resultset