is it possible to get file encoding?
I am working withwindows netsh util
/**filename = path to file*/
privatestatic BufferedReader readFileWithBufferedReader(String filename){
FileInputStream fis =null;
InputStreamReader sr=null;
BufferedReader r=null;
try{
fis =new FileInputStream(filename);
}catch (FileNotFoundException ex){
ex.printStackTrace();
}//fis catch
try{
/*creating InputStreamReader with encoding param*/
sr =new InputStreamReader(fis,"Cp866"/*"Cp1251"*/);
System.out.println("encoding ::: " +sr.getEncoding());
}catch (UnsupportedEncodingException ex){
ex.printStackTrace();
}//sr catch
/*wrapping to BufferedReader*/
br =new BufferedReader( sr);
System.out.println("YES!!!");
return br;
}
I getInputStream from console. I set encoding as "cp866" (it's O.K.)
Then, I save stream to file.
Then user can open this file and get config from file.
The problem is in open file procedure.
I do not know file encoding: it can be "cp1251" (windows cyrillic) or it can be "cp866" (cmd output).
So if user tries to open "cp1251" file with "cp866" encoding, he gets unreadable characters.
Is it possible to get file encoding and then re-create InputStreamReader with proper encoding?

