2012-05-04 281 views
1

我得到ByteArrayOutputStream相机,并希望将此视频流存储到SD卡作为文件,文件扩展名将是任何东西。在SD卡中存储ByteArrayOutputStream

我如何获取流并将其存储到SD卡中,因为我正在获取实时相机流并想要在SD卡中持续更新。

您能否给我提供一个与相机流式传输相关的示例教程。

谢谢。

回答

4
private void save(ByteArrayOutputStream os){ 
     FileOutputStream fos; 
     try { 
      fos = new FileOutputStream("/sdcard/your_position"); 
      os.writeTo(fos); 
      os.flush(); 
      fos.flush(); 
      os.close(); 
      fos.close(); 
     } catch (FileNotFoundException e) { 
      e.printStackTrace(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     }   
    } 

希望能解决您的问题。