Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.        //old
  2. try {
  3.             in = getBaseContext().getContentResolver().openInputStream(imageUri);
  4.         } catch (IOException e) {
  5.             e.printStackTrace();
  6.         } catch (NullPointerException e) {
  7.             e.printStackTrace();
  8.             return;
  9.         }
  10.         byte[] buf = new byte[0];
  11.         try {
  12.             assert in != null;
  13.             buf = new byte[in.available()];
  14.             while (in.read(buf) != -1) ;
  15.         } catch (IOException e) {
  16.             e.printStackTrace();
  17.         } catch (NullPointerException e) {
  18.             e.printStackTrace();
  19.             return;
  20.         }
  21.  
  22. //new
  23. try (InputStream in = getBaseContext().getContentResolver().openInputStream(imageUri)) {
  24.             if (in != null) {
  25.                 buf = new byte[in.available()];
  26.                 while (in.read(buf) != -1) ;
  27.             }
  28.         } catch (IOException e) {
  29.             e.printStackTrace();
  30.         } catch (NullPointerException e) {
  31.             e.printStackTrace();
  32.             return;
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement