当前位置: 代码迷 >> Java Web开发 >> jxl linux 下中文乱码救命!
  详细解决方案

jxl linux 下中文乱码救命!

热度:406   发布时间:2016-04-17 14:16:59.0
jxl linux 下中文乱码大虾救命!!!
excel文件数据导入oracle数据库,在window下发布是正常的,
resin,red   hand,环境,将本地文件上传至下面路径:
/adcweb/resin-2.1.17/webapps/temp/temp_excel/0706021701160367
读文件内容,resin报了下面的错
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file
Warning:     URL   ?愀?????砀?愀??攀?????????   is   malformed.     Trying   a   file

下面是从文件中读出了后打印出来的结果:
-------------------strc0j   ==   a
-------------------strc1j   ==   ?
-------------------AAA-strc1j   ==   ?
-------------------BBB-strc1j   ==   ?
-------------------CCC-strc1j   ==   ?
-------------------DDD-strc1j   ==   ?
-------------------EEE-strc1j   ==   ???
-------------------FFF-strc1j   ==   ?
其中?部分在excel文件中对应的全部是汉字,
部分编码如下:
WorkbookSettings   workbookSettings=new   WorkbookSettings();
workbookSettings.setEncoding( "GB2312 ");   //关键代码,解决中文乱码,却没有预想的结果
Workbook   rwb   =   Workbook.getWorkbook(fileStream,workbookSettings);
……
……
……
……
                int   intRows   =   rs.getRows();
                for   (int   j   =   1;   j   <   intRows;   j++)   {
                    //从第一行(不读第0行表头)开始读
                    Cell   c00   =   rs.getCell(0,   j);   //名称
                    String   strc0j   =   c00.getContents();
…………
…………
                  System.out.println( "-------------------strc0j   ==   "   +   strc0j);

*********************************************************************
急!急!急!请大虾帮忙解决

------解决方案--------------------
自己先顶一下
补充我也作了java中文转换:
System.out.println( "strc1j = " + strc1j);
System.out.println(strc1j.getBytes());//2
System.out.println(strc1j.getBytes( "GB2312 "));//3
System.out.println(strc1j.getBytes( "ISO8859_1 "));//4
System.out.println(new String(strc1j.getBytes()));//5
System.out.println(new String(strc1j.getBytes(), "GB2312 "));//6
System.out.println(new String(strc1j.getBytes(), "ISO8859_1 "));//7
System.out.println(new String(strc1j.getBytes( "GB2312 ")));//8
System.out.println(new String(strc1j.getBytes( "GB2312 "), "GB2312 "));//9
System.out.println(new String(strc1j.getBytes( "GB2312 "), "ISO8859_1 "));//10
System.out.println(new String(strc1j.getBytes( "ISO8859_1 ")));//11