File f = new File(path, fileName);
        if(!f.exists())
        {
            try {
                f.createNewFile();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        FileOutputStream fos;
        try {
            fos = new FileOutputStream(f);
            fos.write(byteArray);
           
            //byteArray这是一个字节数组[],是图象转换而来的,现在就是要将这个转换过来的数组再转换回图象文件            fos.close();
            
            InputStream in = new FileInputStream(f);             FileSystemUtils.save(f,in); 
            
            f.delete();//delete it after using it
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }//把这段执行完后生成一个图象文件,但是文件大小为零,

解决方案 »

  1.   

    这代码写得,楼主没睡醒吧。把这几行删掉:            InputStream in = new FileInputStream(f);            FileSystemUtils.save(f,in);
               
                f.delete();//delete it after using it 
      

  2.   

      InputStream in = new FileInputStream(f);            FileSystemUtils.save(f,in);
               
                f.delete();//delete it after using it 这三句在这里有用吗?或是做其他的处理..如果单是保存byteArray的数据,不用上面三句就可以了......另外,图片用二进制流读写方便..