首页 > 代码库 > 拷贝文件

拷贝文件

private void copyBigDataToSD(String strOutFileName) throws IOException
{
File fData = http://www.mamicode.com/new File(strOutFileName);
try{
if (!fData.exists()){ //not exist, copy
InputStream myInput;
OutputStream myOutput = new FileOutputStream(strOutFileName);
myInput = this.getAssets().open("data.bin");
byte[] buffer = new byte[1024];
int length = myInput.read(buffer);
while(length > 0)
{
myOutput.write(buffer, 0, length);
length = myInput.read(buffer);
}

myOutput.flush();
myInput.close();
myOutput.close();
}
}catch (Exception e ){
Log.e(TAG, "file data.bin ERROR!");
}
}

拷贝文件