无法提取谷歌Play应用程序下载OBB文件 [英] Unable to extract obb file downloaded from google play application

查看:3134
本文介绍了无法提取谷歌Play应用程序下载OBB文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我implmeneted APK扩展successfully.And在Android-> Obb-> PackageName-> com.1.com.packagename.obb

但是,当我去解我收到issue.Eof文件例外 在日志中解压缩exception2。

例外: - java.io.FileNotFoundException:/storage/sdcard0/.MyApp/BGP050@2x.jpg:打开失败:ENOENT(没有这样的文件或目录)

请回复,如果任何人有提前的想法感谢....

功能从打电话来解压文件

 公共无效提取物()
{

            字符串的packageName = getApplicationContext()getPackageName()。

            文件根= Environment.getExternalStorageDirectory();
            文件expPath =新的文件(root.toString()+/安卓/ OBB /+的packageName);

            如果(expPath.exists()){
                字符串strMainPath = NULL;
                尝试 {
                    strMainPath = expPath +文件分割符+为主。
                        + getPackageManager()。getPackageInfo(
                                    getPackageName(),0).version code +。
                            +的packageName +.obb;


                Log.e(提取文件路径,===>+ strMainPath);

                文件F =新的文件(strMainPath);
                如果(f.exists()){
                    Log.e(提取从文件路径,===>不存在);
                }
                其他
                {
                    Log.e(提取从文件路径,===>存在);
                }

                标志= extractZip(strMainPath,Environment.getExternalStorageDirectory()+/+ Constant.FOLDERNAME);

                Log.e(===>中压缩ZIP后+标志);
                }赶上(的NameNotFoundException E){
                    // TODO自动生成的catch块
                    e.printStackTrace();
                }

            }

}
 

功能如下

 私人布尔extractZip(字符串pathOfZip,字符串pathToExtract)
 {


        INT BUFFER_SIZE = 1024;
        INT大小;
        byte []的缓冲区=新的字节[BUFFER_SIZE];


        尝试 {
            文件F =新的文件(pathToExtract);
            如果(!f.isDirectory()){
                f.mkdirs();
            }
            ZipInputStream ZIN =新ZipInputStream(新的BufferedInputStream(新的FileInputStream(pathOfZip),BUFFER_SIZE));
            尝试 {
                ZipEntry的泽= NULL;
                而((泽= zin.getNextEntry())!= NULL){
                    字符串路径= pathToExtract +/+ ze.getName();

                    如果(ze.isDirectory()){
                        文件unzipFile =新的文件(路径);
                        如果(!unzipFile.isDirectory()){
                            unzipFile.mkdirs();
                        }
                    }
                    其他 {
                        FileOutputStream中出=新的FileOutputStream(路径,FALSE);
                        的BufferedOutputStream FOUT =新的BufferedOutputStream(满分,BUFFER_SIZE);
                        尝试 {
                            而((大小= zin.read(缓冲液,0,BUFFER_SIZE))!=  -  1){
                                fout.write(缓冲液,0,大小);
                            }

                            zin.closeEntry();
                        }赶上(例外五){
                            Log.e(异常,解压异常1:+ e.toString());
                        }
                        最后 {
                            fout.flush();
                            fout.close();
                        }
                    }
                }
            }赶上(例外五){
                Log.e(异常,解压缩exception2:+ e.toString());
            }
            最后 {
                zin.close();
            }
            返回true;
        }
        赶上(例外五){
            Log.e(异常,解压缩异常:+ e.toString());
        }
        返回false;

    }
 

解决方案

试试这个: -

在很努力终于让我找到一个solution.I是子平整个文件夹的子文件夹也通过右键单击ubuntu12.04。

不过,在那之后我尝试选择所有图像/文件,然后压缩他们新的文件夹。 通过上面的codeI能够成功地提取出所有的文件。

感谢......

I implmeneted apk expansion successfully.And obb file downloaded at Android->Obb->PackageName->com.1.com.packagename.obb

But when i go to extract i am getting issue.Eof file exception in log Unzip exception2.

Exception:- java.io.FileNotFoundException: /storage/sdcard0/.MyApp/BGP050@2x.jpg: open failed: ENOENT (No such file or directory)

Please reply if anyone have idea thanks in advance....

Function From calling to extract file

public void extract()
{

            String packageName = getApplicationContext().getPackageName();

            File root = Environment.getExternalStorageDirectory();
            File expPath = new File(root.toString() + "/Android/obb/" + packageName);

            if (expPath.exists()) {
                String strMainPath = null;
                try {
                    strMainPath = expPath + File.separator + "main."
                        + getPackageManager().getPackageInfo(
                                    getPackageName(), 0).versionCode + "."
                            + packageName + ".obb";


                Log.e("Extract File path", "===>"+strMainPath);

                File f=new File(strMainPath);
                if(f.exists()){
                    Log.e("Extract From File path", "===> not exist");
                }
                else
                {
                    Log.e("Extract From File path", "===> exist");
                }

                flag = extractZip(strMainPath,Environment.getExternalStorageDirectory()+"/"+Constant.FOLDERNAME);

                Log.e("After Extract Zip", "===>"+flag);
                } catch (NameNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

}

Function is below

private boolean extractZip(String pathOfZip,String pathToExtract)
 {


        int BUFFER_SIZE = 1024;
        int size;
        byte[] buffer = new byte[BUFFER_SIZE];


        try {
            File f = new File(pathToExtract);
            if(!f.isDirectory()) {
                f.mkdirs();
            }
            ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(pathOfZip), BUFFER_SIZE));
            try {
                ZipEntry ze = null;
                while ((ze = zin.getNextEntry()) != null) {
                    String path = pathToExtract  +"/"+ ze.getName();

                    if (ze.isDirectory()) {
                        File unzipFile = new File(path);
                        if(!unzipFile.isDirectory()) {
                            unzipFile.mkdirs();
                        }
                    }
                    else {
                        FileOutputStream out = new FileOutputStream(path, false);
                        BufferedOutputStream fout = new BufferedOutputStream(out, BUFFER_SIZE);
                        try {
                            while ( (size = zin.read(buffer, 0, BUFFER_SIZE)) != -1 ) {
                                fout.write(buffer, 0, size);
                            }

                            zin.closeEntry();
                        }catch (Exception e) {
                            Log.e("Exception", "Unzip exception 1:" + e.toString());
                        }
                        finally {
                            fout.flush();
                            fout.close();
                        }
                    }
                }
            }catch (Exception e) {
                Log.e("Exception", "Unzip exception2 :" + e.toString());
            }
            finally {
                zin.close();
            }
            return true;
        }
        catch (Exception e) {
            Log.e("Exception", "Unzip exception :" + e.toString());
        }
        return false;

    }

解决方案

Try this:-

After very struggle finally i found a solution.I was ziping the whole folder with subfolder also by right click in ubuntu12.04.

But After that i tried select all images/files then zip them to new folder. By the above code i was able to extracted all the files successfully.

Thanks......

这篇关于无法提取谷歌Play应用程序下载OBB文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆