Java : How to determine the correct charset encoding of a stream
i want to get the file encoding type runtime for pertiqular file.
System.getProperties("file.encoding");
the above code display the same encoding type for all input file.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See Marcelos comment – there are some libraries you can use to guess the encoding of a file, but you can never determine it for sure, unless you know before-hand. There is no “standard” information in arbitrary text-files to indicate which encoding has been used to write it. Specific file formats may include encoding information, but that would be in some proprietary way, specific to that file format.