Java Text File Encoding

后端 未结 4 1880
逝去的感伤
逝去的感伤 2020-12-17 18:54

I have a text file and it can be ANSI (with ISO-8859-2 charset), UTF-8, UCS-2 Big or Little Endian.

Is there any way to detect the encoding of the file to read it pr

4条回答
  •  有刺的猬
    2020-12-17 19:01

    If your text file is a properly created Unicode text file then the Byte Order Mark (BOM) should tell you all the information you need. See here for more details about BOM

    If it's not then you'll have to use some encoding detection library.

提交回复
热议问题