Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't create File from assets file #5

Open
shakeri-mreza opened this issue Jul 18, 2018 · 1 comment
Open

can't create File from assets file #5

shakeri-mreza opened this issue Jul 18, 2018 · 1 comment

Comments

@shakeri-mreza
Copy link

I have my .pem file placed in assets folder.
how can I create a java file from it ?

@hkawii
Copy link

hkawii commented Aug 26, 2018

just place it in raw folder instead of assets and use the following code

  InputStream inputStream = MyApplication.getmInstance().getResources().openRawResource(R.raw.ccert);
        File certificate = File.createTempFile("pre", "suf");
        copyFile(inputStream, new FileOutputStream(certificate)); 
    private static void copyFile(InputStream in, OutputStream out) throws IOException {
        byte[] buffer = new byte[1024];
        int read;
        while((read = in.read(buffer)) != -1){
            out.write(buffer, 0, read);
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants