2012-05-04 276 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(); 
     }   
    } 

希望能解決您的問題。