String
public String(byte[] bytes)Constructs a new String by decoding the specified array of bytes using the platform's default charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array. The behavior of this constructor when the given bytes are not valid in the default charset is unspecified. The CharsetDecoder class should be used when more control over the decoding process is required. 
Parameters:
bytes - the bytes to be decoded into characters
Since: 
JDK1.1 

解决方案 »

  1.   

    "如果写成out.print(new String(byte[]));这种形式应该是不对的"如果字段里存放的是"111"这种简单文本数据可以
    但是如果复杂了以后,就不行了,具体复杂到什么程度不行我就不知道了,反正楼上的不对
      

  2.   

    如果你的这个数据是从数据库的一个字段取出来的,简单的构造一个String肯定是不对的
    因为一般来说数据库字段使用了数据流的都是大对象,例如序列化的Object或者Image,取出来的byte[]需要保存成对应的对象才可以,,
      

  3.   

    我在数据库中存的word这种东西
    谁能不能发个例子示例一下,好学习一下呀
      

  4.   

    如果是word的话大致如下:(其它文件或图片的操作类似)
    response.setContentType("application/msword");
    OutputStream out=response.getOutputStream();
    out.write(byte[]);
      

  5.   

    response.setContentType("application/msword;charset=gb2312");
    InputStream in = rs.getBinaryStream(word字段);
    OutputStream out = response.getOutputStream();
    byte[] bytes = new byte[4096];
    while(in.read(bytes,0,4096) != -1){
      out.write(bytes);
    }
    out.flush();
    in.close();
    out.close();