Android &引用;Src";未作为文件或资源找到。in PdfReader reader=新PdfReader(src)

Android &引用;Src";未作为文件或资源找到。in PdfReader reader=新PdfReader(src),android,itext,Android,Itext,我正在尝试用密码加密pdf。即使pdf文件存在于存储器中,其显示文件也不存在。路径也是正确的。我还包括了读写权限 private void Write() { // Need to ask for write permissions on SDK 23 and up, this is ignored on older versions if (ContextCompat.checkSelfPermission(MainActivity.this, Man

我正在尝试用密码加密pdf。即使pdf文件存在于存储器中,其显示文件也不存在。路径也是正确的。我还包括了读写权限

private void Write() {

    // Need to ask for write permissions on SDK 23 and up, this is ignored on older versions
    if (ContextCompat.checkSelfPermission(MainActivity.this,
            Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED)
    {

        ActivityCompat.requestPermissions(MainActivity.this,
                new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
    }
}



public void file_manager(View view) {
    myfileintent = new Intent(Intent.ACTION_GET_CONTENT);
    myfileintent.setType("*/*");
    startActivityForResult(myfileintent, 10);
}



@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    switch (requestCode) {
        case 10:
            path = data.getData().getPath();
            akhil = new File(path);
            break;
    }
}


public void encrypt(View v){
    try {
        encryptPdf(Environment.getExternalStorageDirectory().getAbsolutePath()+path,path);
    } catch (IOException e) {
        e.printStackTrace();


    } catch (DocumentException e) {
        e.printStackTrace();
    }
}

public void encryptPdf(String src, String dest) throws IOException, DocumentException {

    File z=new File(src);

        Toast.makeText(this, src, Toast.LENGTH_SHORT).show();

        PdfReader reader = new PdfReader(src);
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
        stamper.setEncryption(USER, OWNER,
                PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128 | PdfWriter.DO_NOT_ENCRYPT_METADATA);
        stamper.close();
        reader.close();

}
《在android studio中运行》正在展示这一点


W/System.err:java.io.IOException:/storage/simulated/0/external_files/Download/1484820337WBJEE Mathematics Sample Paper 2.pdf未作为文件或资源找到。

您解决了吗?我这里也有同样的问题。你解决了吗?我这里也有同样的问题。tks