I'm trying to read the flow from the system console but I have some problems with the encoding. As I'm french, my keyboard has some special chars such as 'é', 'è', 'à', etc...
When I put the content of the console into a text area, I got something like that:
Le volume dans le lecteur C s'appelle DisqueC
Le num?ro de s?rie du volume est CE7........
3 fichier(s) 20?229 octets
5 R?p(s) 450?096?623?616 octets libres
It automaticaly replaces special chars by '?' and there is also a problem with the size.
I read the content of the console like that:
BufferedReader stdInput = new BufferedReader(new InputStreamReader(child.getInputStream(), "UTF-8"));
BufferedReader stdError = new BufferedReader(new InputStreamReader(child.getErrorStream(), "UTF-8"));
String line;
byte[] lineBytes;
while ((line = stdInput.readLine()) != null)
{
lineBytes = line.getBytes("UTF-8");
buffer.append("\t\t" + new String(lineBytes, "UTF-8") + "\n");
}
stdInput.close();
while ((line = stdError.readLine()) != null)
{
lineBytes = line.getBytes("UTF-8");
buffer.append("\t\t" + new String(lineBytes, "UTF-8") + "\n");
}
stdError.close();
Then the buffer is sent through a socket and I display it like that into a jTextArea:
textArea.append(new String(console_output.getBytes(), "UTF-8"););
So, can anyone tell me why I have this problem with encoding?
Thanks.