title: Android- how can I convert android.net.Uri object to java.net.URI object?
body: <p>I am trying to get a <code>FileInputStream</code> object on an image that the user selects from the picture gallery. This is the android <code>URI</code> returned by <code>android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI</code></p>
  
  <pre><code>content://media/external/images/media/3
  </code></pre>
  
  <p>When I try to construct a java URI object from this object, I get an <code>IllegalArgumentException</code> with the exception description <strong>Expected file scheme in URI: content://media/external/images/media/3</strong> whereas the android URI shows the scheme as <strong>content</strong></p>
  
  <p><strong>Update</strong>:
  Never found a solution for the original question. But if you want the byte stream of an image in the pictures gallery, this piece of code will do that.</p>
  
  <pre><code>Bitmap bitmap = Media.getBitmap(getContentResolver(), imageUri);
  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
  ByteArrayInputStream fileInputStream = new ByteArrayInputStream(bytes.toByteArray());
  </code></pre>