I am trying to find the encoding of a file using the java program. But it always providing the UTF-8 as the output. Even though it is an ANSI file.
import java.io.InputStream
import java.io.FileInputStream
import java.io.BufferedInputStream
import java.io.InputStreamReader
new InputStreamReader(new FileInputStream("FILE_NAME")).getEncoding
The library is old and looks no proper support for that. https://code.google.com/archive/p/juniversalchardet/
Some are so many answers, that say we can find the encoding of the file like Java : How to determine the correct charset encoding of a stream
These solutions doesnt look good. According to @ Jörg W Mittag We cannot find the encoding of a file for sure.