我是靠谱客的博主 魁梧云朵,这篇文章主要介绍Android读取asset目录的文件转File,现在分享给大家,希望可以做个参考。

直接调用writeBytesToFile: 
writeBytesToFile(getActivity().getAssets().open("xxx文件名"),file);

public static void writeBytesToFile(InputStream is, File file) throws IOException{
    FileOutputStream fos = null;
    try {  
        byte[] data = new byte[2048];
        int nbread = 0;
        fos = new FileOutputStream(file);
        while((nbread=is.read(data))>-1){
            fos.write(data,0,nbread);              
        }
    }
    catch (Exception ex) {
        logger.error("Exception",ex);
    }
    finally{
        if (fos!=null){
            fos.close();
        }
    }
}

最后

以上就是魁梧云朵最近收集整理的关于Android读取asset目录的文件转File的全部内容,更多相关Android读取asset目录内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(57)

评论列表共有 0 条评论

立即
投稿
返回
顶部