title: How can I get File from URI in Android?
body: <p>I am trying to read a PDF file but it's throwing a <code>NoSuchFileException</code>. I have seen some solution for this but nothing seems to work in my case. I want to read the PDF file. Below is my code:</p>
  
  <pre><code> private void requestForResume() {
      Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
      intent.setType("*/*");
      intent.addCategory(Intent.CATEGORY_OPENABLE);
      Intent chooser = Intent.createChooser(intent, "Upload PDF File");
      startActivityForResult(chooser, REQUEST_CODE);
  }
  </code></pre>
  
  <p>Here is how I am converting to file:</p>
  
  <pre><code>@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
  
      if (requestCode == REQUEST_CODE) {
          Uri uri = data.getData();
          String fileName = uri.getLastPathSegment();
  
          File resumeFile=new File(uri.getPath());
          try {
  
              PDDocument pdfResume=PDDocument.load(resumeFile);
              PDFTextStripper stripper=new PDFTextStripper();
              String resumeText=stripper.getText(pdfResume);
              Log.d("location",resumeText);
          } catch (IOException e) {
              Log.d("location","unable to load pdf"+e.toString());
          }
  
          fileEditText.setText(fileName);        
      }
  }
  </code></pre>
  
  <p>Please help me where I am wrong.</p>