2014-09-05 113 views
0

我想写一个字节数组到文件夹。字节数组是通过将zip文件转换为字节数组创建的,当我将其转换回来时,我想以解压缩(提取)的格式写入文件。将字节数组写入文件夹

我的代码如下。在线路

FileOutputStream fileOuputStream = new FileOutputStream(f); 

拒绝访问异常抛出。我想将字节数组内容直接写入解压缩格式的文件夹中。有什么办法可以直接做,而不是以压缩格式写入字节数组,然后解压缩它?

private void (byte[] content, String baseFolder) { 

    File f = new File(baseFolder,"TestFolder"); 

    if (!f.isDirectory()) 
     f.mkdirs(); 
    if (!f.canWrite()) 
     f.setWritable(true); 

    try { 
     FileOutputStream fileOuputStream = new FileOutputStream(f); 
     fileOuputStream.write(content); 
     fileOuputStream.close(); 
    } catch (Exception ex) { 
    } 
} 

回答