Reading text files without specifying the encoding?
807603Oct 22 2007 — edited Oct 24 2007I have looked everywhere for a solution, but I can't find one. The problem is that I'm using codes that everybody is using, but for some reason, my codes aren't working.
I want to be able to open up text files in Java without having to specify the encoding for the files that I'm going read, because I have no idea which encoding they will use.
But even when specifying UTF-8 to be encoding of the file to read, it doesn't work correctly:
FileInputStream fileIS= new FileInputStream("somefile.txt");
Reader reader = new BufferedReader(new InputStreamReader(fileIS, Charset.forName("UTF-8")));
EVERYWHERE I look, ppl are using these codes! But it doesn't work, some characters (such as the Euro sign) are displayed as squares.
However, I want to be able to read not only UTF-8 files but anything that Java supports. Any ideas?
Edited by: Stalfos on Oct 22, 2007 12:22 PM