FileOutputStream fis = new FileOutputStream("C:/xxx.xxx");
ByteArrayInputStream bais = new ByteArrayInputStream(b);
byte[] buffer = new byte[8*1024];
int count = 0;
while ((count = bais.read(buffer)) != 0) 
  fis.write(buffer, 0, count);
fis.close();

解决方案 »

  1.   

    HashMap fileByte=new HashMap(); 
    fileByte.put("附件名1", byte[]字节类型); 
    fileByte.put("附件名2", byte[]字节类型); 怎样把HashMap中的“byte[]字节类型“结合以下代码生成文件?
    FileOutputStream fis = new FileOutputStream("C:/xxx.xxx");
    ByteArrayInputStream bais = new ByteArrayInputStream(b);
    byte[] buffer = new byte[8*1024];
    int count = 0;
    while ((count = bais.read(buffer)) != 0) 
      fis.write(buffer, 0, count);
    fis.close();
      

  2.   

    晕了,从HashMap中取值总该会吧,byte[] b = fileByte.get("你要取出的名字")
    FileOutputStream fis = new FileOutputStream("C:/xxx.xxx"); 
    ByteArrayInputStream bais = new ByteArrayInputStream(b); 
    byte[] buffer = new byte[8*1024]; 
    int count = 0; 
    while ((count = bais.read(buffer)) != 0) 
      fis.write(buffer, 0, count); 
    fis.close(); 红字部分就是你取出的字节数组.
      

  3.   

    把错“类型不匹配:不能从 Object 转换为 byte[]”HashMap fileByte=new HashMap(); 
    fileByte.put("附件名1", byte[]字节类型); 
    fileByte.put("附件名2", byte[]字节类型); 
    String fjName="";
    String keyValue="";
    Iterator keyIter= fileData.keySet().iterator(); 
    while(keyIter.hasNext()){
    keyValue=(String)keyIter.next();
    byte[] b = fileData.get(keyValue); 
    FileOutputStream fis = new FileOutputStream("C:/xxx.xxx"); 
    ByteArrayInputStream bais = new ByteArrayInputStream(b); 
    byte[] buffer = new byte[8*1024]; 
    int count = 0; 
    while ((count = bais.read(buffer)) != 0)
      fis.write(buffer, 0, count); 
    fis.close(); 

    }