public static void copyAssetsFiles2Dir(Context context,String filename){
InputStream is=null;
FileOutputStream fos=null;
try {
is=context.getAssets().open(filename);
int filesize=is.available();
byte[] buffer=new byte[0];
if(filesize>0){
buffer=new byte[filesize];
}
File dir = context.getDir("文件名", context.MODE_PRIVATE);
String p=dir.getAbsolutePath();
File fileso=new File(p+"/"+filename);
if(!fileso.exists()){
fileso.createNewFile();
}
fos=new FileOutputStream(fileso);
int t=0;
while((t=is.read(buffer))!=-1){
fos.write(buffer,0,t);
}
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(null!=fos){
try{
fos.close();
}catch(Exception e){}
}
if(null!=is){
try{
is.close();
}catch(Exception e){}
}
}
}
InputStream is=null;
FileOutputStream fos=null;
try {
is=context.getAssets().open(filename);
int filesize=is.available();
byte[] buffer=new byte[0];
if(filesize>0){
buffer=new byte[filesize];
}
File dir = context.getDir("文件名", context.MODE_PRIVATE);
String p=dir.getAbsolutePath();
File fileso=new File(p+"/"+filename);
if(!fileso.exists()){
fileso.createNewFile();
}
fos=new FileOutputStream(fileso);
int t=0;
while((t=is.read(buffer))!=-1){
fos.write(buffer,0,t);
}
fos.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(null!=fos){
try{
fos.close();
}catch(Exception e){}
}
if(null!=is){
try{
is.close();
}catch(Exception e){}
}
}
}