Skip to content

Commit

Permalink
Cleanup: use InputStream.transferTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisguse committed Nov 24, 2023
1 parent 25d4daa commit 8b7063d
Showing 1 changed file with 1 addition and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ public void close() {
* @param trackId the track's id which image belongs to.
* @param fileName the file name
*/
@Deprecated //TODO Use JDK9's inputStream.transferTo() instead of manual buffer
private void readAndSaveImageFile(ZipInputStream zipInputStream, Track.Id trackId, String fileName) throws IOException {
if (trackId == null || "".equals(fileName)) {
return;
Expand All @@ -238,11 +237,7 @@ private void readAndSaveImageFile(ZipInputStream zipInputStream, Track.Id trackI
File file = new File(dir, fileName);

try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
byte[] buffer = new byte[4096];
int count;
while ((count = zipInputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, count);
}
zipInputStream.transferTo(fileOutputStream);
}
}
}

2 comments on commit 8b7063d

@pstorch
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dennisguse I think this change needs to be reverted. The Linter warns about the needed API level 33.

@dennisguse
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx.My AndroidStudio didn't complain until I started the linter.

Please sign in to comment.