在linux服务器上生成jsp文件,中文变乱码的问题

来源:互联网 发布:js base64 utf8 编辑:程序博客网 时间:2024/05/22 02:04

代码:

 

//创建一个向指定 File 对象表示的文件中写入数据的文件输出流。如果第二个参数为 true,则将字节写入文件末尾处,而不是写入文件开始处。
  FileOutputStream   fos = new FileOutputStream(tempString,true); //tempString是生成的文件的名字;
  //创建使用给定字符集的 OutputStreamWriter。

  //没改之前是PrintWriter pw = new PrintWriter(new FileOutputStream(tempString));结果中文全变问号了。
  PrintWriter pw = new   PrintWriter(new   OutputStreamWriter(fos,"GB2312"),true);   
  pw.println(result);//写内容result为文件内容;
  pw.close();

 

 

 

转自:http://topic.csdn.net/t/20060330/15/4651480.html#