| | |
| | | |
| | | OutputStream outputStream = new FileOutputStream( new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/"+context.getPackageName(), assertfileName)); |
| | | byte[] bytes = new byte[1024]; |
| | | int len = 0; |
| | | while ((len =inputStream.read(bytes))>0){ |
| | | outputStream.write(bytes,0,len); |
| | | } |
| | | outputStream.close(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | /** |
| | | * 拷贝assert目录下的文件到 安装包目录下 |
| | | * @param context |
| | | * @param assertfileName |
| | | */ |
| | | public static void copyAssertFileToCache(Context context,String assertfileName){ |
| | | |
| | | try { |
| | | InputStream inputStream = null; |
| | | try { |
| | | inputStream = context.getAssets() |
| | | .open(assertfileName); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // deleteFile(context.getPackageName()+"/",assertfileName); |
| | | |
| | | OutputStream outputStream = new FileOutputStream( new File(context.getFilesDir(), assertfileName)); |
| | | // OutputStream outputStream = context.openFileOutput(assertfileName,Context.MODE_PRIVATE+Context.MODE_WORLD_WRITEABLE); |
| | | byte[] bytes = new byte[1024]; |
| | | while ((inputStream.read(bytes))>0){ |
| | | outputStream.write(bytes); |
| | | } |