Is there way to check charset encoding of .txt file with Java?

Zookey picture Zookey · Jun 13, 2012 · Viewed 29.1k times · Source

Is there way to check is text file (.txt) encoded with Unicode or UTF-8 with Java?

Answer

Paul Grime picture Paul Grime · Jun 13, 2012

You cannot know with absolute certainty which charset is used in the general case. I found this to be a good read.

http://illegalargumentexception.blogspot.co.uk/2009/05/java-rough-guide-to-character-encoding.html

Especially the section Automatic detection of encoding.