3

Possible Duplicate:
Java : How to determine the correct charset encoding of a stream

i'm trying to read an ANSI text file in java but, i don't know the encoding of the text inside , is there any way to detect the encoding of text file before getting it using FileInputStream ?

Community
  • 1
  • 1

1 Answers1

0

I don't think it's possible to know the encoding of a text file before actually reading it. You have to read a couple of bytes before trying to determine it's encoding.

The tool mentioned in the comments asks you to do exactly that (actually it says several thousands bytes) before detecting the encoding of a file.

betomontejo
  • 1,657
  • 14
  • 26