如果文件是GBK编码的,读取文件前能怎么样确认文件的编码方式呢

解决方案 »

  1.   

    你的读取平台是?jsp还是……
      

  2.   


    这个文件是别人,按照事先约定的规则制定的,我拿到这个文件后想要先确定这个文件是不是GBK的如果是就继续操作,如果不是则不进行处理
      

  3.   

    http://jchardet.sourceforge.net/
    What is jchardet ? 
    jchardet is a java port of the source from mozilla's automatic charset detection algorithm. The original author is Frank Tang. What is available here is the java port of that code. The original source in C++ can be found from http://lxr.mozilla.org/mozilla/source/intl/chardet/ More information can be found at http://www.mozilla.org/projects/intl/chardet.html
      

  4.   

    如果双方能够约定,则在文件的指定的位置写一个汉字,如果这个汉字能用GBK正确读出就是GBK编码了。