高分求救 我在UNIX系统上 读取文件中文乱码问题 我在UNIX系统上 读取文件中文乱码问题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 UNIX默认的本地机编码是GBK之类的?如果你的程序再windows下没乱码 就考虑下是不是环境问题 否则就看看你代码是否有问题是否需要转码 我用String enc = System.getProperty("file.encoding"); System.out.println("===="+enc);在服务器(unix)输出后 是 ISO8859-1 我本地(windows 操作系统)是 GBK 不知道怎样才能解决 转码不就可以了?Unix-->WinString win=new String(unix.getBytes("ISO8859-1"),"GBK");Win-->UnixString unix=new String(win.getBytes("GBK"),"ISO8859-1"); private void OutputXML(Document docXML, File strFilename) { XMLOutputter fmt = new XMLOutputter(); try { //输出文件对象 Format format = Format.getPrettyFormat(); format.setEncoding("GBK"); fmt.setFormat(format); fmt.output(docXML, System.out);//这里输出中文 FileWriter fwXML = new FileWriter(strFilename); fmt.output(docXML, fwXML); //变?? fwXML.close(); }catch (Exception e) { e.printStackTrace(); } } 求救 你的Format类和XMLOutputter类是哪个包里的?怎么方法和我见到的不一样呀!?如果你用jdom,可以直接读iso8859的XML文件,不用转码了 eclipse叫人恼火的问题 Image对象截取其一部分,保存到Image对象中 怎么变相的继承String类呢?【详情见贴内】 smartupload上传文件 如果磁盘已满 有提示么? 在线请教:一个类多个实例,怎么做? java聊天程序? jar classpath 大家出出主意! *** 高分, 高难度问题, 请帮助(和ClassLoader) 有关。 **** Collection,List都是接口,为什么我可以这么用? 送分10 JFreeChart生成图片在jsp中显示为框框 ObjectOutputStream和ObjectInputStream的问题!
如果你的程序再windows下没乱码 就考虑下是不是环境问题 否则就看看你代码是否有问题是否需要转码
在服务器(unix)输出后 是 ISO8859-1
我本地(windows 操作系统)是 GBK
不知道怎样才能解决
Unix-->Win
String win=new String(unix.getBytes("ISO8859-1"),"GBK");
Win-->Unix
String unix=new String(win.getBytes("GBK"),"ISO8859-1");
XMLOutputter fmt = new XMLOutputter();
try {
//输出文件对象
Format format = Format.getPrettyFormat(); format.setEncoding("GBK");
fmt.setFormat(format);
fmt.output(docXML, System.out);//这里输出中文
FileWriter fwXML = new FileWriter(strFilename); fmt.output(docXML, fwXML); //变??
fwXML.close();
}catch (Exception e) {
e.printStackTrace();
}
} 求救
如果你用jdom,可以直接读iso8859的XML文件,不用转码了