//                BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file1));
//                if (attachFile != null) {
//                    out.write(attachFile);
//                }
//                out.close();用这样的形式,没有办法设置charset。 还是不需要设置啊 
attachFile 是byte[]形式的。还有其他的什么方法吗

解决方案 »

  1.   

    不需要设置charset,流没有编码,只有字符流和字节流
      

  2.   

    那生成之后的文件的编码格式可以设置吗?
    我的 byte[] 是从数据库中的BLOB类型中取出来的,byte[]这个就是流的形式吧
      

  3.   

    给你写了一个,你参考一下:FileWriter fw = null;
    PrintWriter pw = null;
    try {
    fw = new FileWriter("c:/123.txt");
    String str = new String("哈尔滨工业大学");
    pw = new PrintWriter(fw);
    pw.println(str);
    pw.flush();
    System.out.println("写入完成");
    }catch(Exception e) {
    e.printStackTrace();
    }
      

  4.   

    生成的文件编码格式我没设置过,也不需要设置啊!byte[]这种形式,属于低级字节流,建议你用高级流,速度快,效率高!
      

  5.   

    哦 是字节流就行了,关键从数据库取出来的就是这种byte[] 形式,
      

  6.   

    byte[]和String是可以互相转换的
      

  7.   

    上面已经没有问题了,可是文件名在生成的时候不是用流形式做成的,两个服务器的编码格式是不一样的,、这样传送后会乱码如何解决呢
    AIX的本地系统向LINUX系统传送后,这个文件名就是乱码了。 这样就找不到这个文件了
    如何解决呢
      

  8.   

     session.execCommand("convmv  -f euc-jp -t utf8 /home/* --notest");解决  可以用这个命令,来进行文件的转码