Skip to content

Commit

Permalink
Reduce visibility of convertInputStreamToBase64OutputStream method
Browse files Browse the repository at this point in the history
Summary:
Reduce visibility of convertInputStreamToBase64OutputStream method

chnagelog: [internal] internal

Differential Revision: D49834867

fbshipit-source-id: e7e057fce65a926939d4216acff3aa7a6df7e0e5
  • Loading branch information
mdvacca authored and facebook-github-bot committed Oct 3, 2023
1 parent 0f114b4 commit f7a087d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,28 @@ protected void doInBackgroundGuarded(Void... params) {
mError.invoke(e.getMessage());
}
}
}

String convertInputStreamToBase64OutputStream(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Base64OutputStream b64os = new Base64OutputStream(baos, Base64.NO_WRAP);
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
try {
while ((bytesRead = is.read(buffer)) > -1) {
b64os.write(buffer, 0, bytesRead);
String convertInputStreamToBase64OutputStream(InputStream is) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Base64OutputStream b64os = new Base64OutputStream(baos, Base64.NO_WRAP);
byte[] buffer = new byte[BUFFER_SIZE];
int bytesRead;
try {
while ((bytesRead = is.read(buffer)) > -1) {
b64os.write(buffer, 0, bytesRead);
}
} finally {
closeQuietly(b64os); // this also closes baos and flushes the final content to it
}
} finally {
closeQuietly(b64os); // this also closes baos and flushes the final content to it
return baos.toString();
}
return baos.toString();
}

private static void closeQuietly(Closeable closeable) {
try {
closeable.close();
} catch (IOException e) {
// shhh
private void closeQuietly(Closeable closeable) {
try {
closeable.close();
} catch (IOException e) {
// shhh
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static String getExtraDataAsJson(@Nullable ReadableMap metadata) {
json.close();
extraDataWriter.close();
return extraDataWriter.toString();
} catch (IOException ex) {
} catch (IOException ignored) {
}
return null;
}
Expand Down

0 comments on commit f7a087d

Please sign in to comment.