Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reminder: Close FileOutputStream in handleDownloadSuccess() #119

Closed
dzuluaga opened this issue Aug 4, 2023 · 10 comments
Closed

Reminder: Close FileOutputStream in handleDownloadSuccess() #119

dzuluaga opened this issue Aug 4, 2023 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@dzuluaga
Copy link
Collaborator

dzuluaga commented Aug 4, 2023

In the handleDownloadSuccess() function, please remember to close the fileOutputStream after writing the downloaded data to a file. Proper resource management is essential for reliable and efficient code.

Suggested Solution:
To ensure proper resource management and improve the reliability of the code, we recommend adding the necessary code to close the fileOutputStream after the bytes.writeTo(fileOutputStream) operation.

Example Using Kotlin's use Function:

try {
    FileOutputStream(fileToSave).use { fileOutputStream ->
        bytes.writeTo(fileOutputStream)
        // File was successfully saved
    }
} catch (e: IOException) {
    // Handle the exception here
}
@dzuluaga dzuluaga added the enhancement New feature or request label Aug 4, 2023
@HectorNarvaez
Copy link
Contributor

PR opened #125

@HectorNarvaez
Copy link
Contributor

PR merged

@dzuluaga
Copy link
Collaborator Author

dzuluaga commented Aug 7, 2023

Per my last comment this change is for the sample app, not the README. Please fix it.

@HectorNarvaez
Copy link
Contributor

PR opened #131

@HectorNarvaez
Copy link
Contributor

PR merged

c.c.: @dzuluaga @nelsonwilches @mariomonteroencora @teban1288

@dzuluaga
Copy link
Collaborator Author

dzuluaga commented Aug 8, 2023

LGTM. Thx

@dzuluaga dzuluaga closed this as completed Aug 8, 2023
@dzuluaga
Copy link
Collaborator Author

dzuluaga commented Aug 9, 2023

Per my last comment this change is for the sample app, not the README. Please fix it.

Reopening to address removing it from the README section.

@dzuluaga dzuluaga reopened this Aug 9, 2023
@HectorNarvaez
Copy link
Contributor

PR opened #134

@HectorNarvaez
Copy link
Contributor

PR merged

c.c.: @dzuluaga @nelsonwilches @mariomonteroencora @teban1288

@dzuluaga
Copy link
Collaborator Author

dzuluaga commented Aug 9, 2023

LGTM. Thx

@dzuluaga dzuluaga closed this as completed Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants