文件讀取

public static File CopyDataBase(Context context,int id,String path)
 {
  try
  {
   InputStream  inputStream = context.getResources().openRawResource(id);
   File file = new File(path);
   FileOutputStream fos = new FileOutputStream(file );
   byte[] buff = new byte[1024];
   int len = -1;
   //邊讀邊寫
   while((len = inputStream.read(buff))!=-1)
   {
    fos.write(buff, 0, len);
   }
   fos.close();
   inputStream.close();
   return file;
  } catch (Exception e)
  {
   e.printStackTrace();
   return null;
  }
 }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章