From 8b7063d18bfeaf81baecbd10760fe552da28ca2d Mon Sep 17 00:00:00 2001 From: Dennis Guse Date: Fri, 24 Nov 2023 07:11:22 +0100 Subject: [PATCH] Cleanup: use InputStream.transferTo() --- .../opentracks/io/file/importer/KmzTrackImporter.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmzTrackImporter.java b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmzTrackImporter.java index 321fa79c33..37265b735d 100644 --- a/src/main/java/de/dennisguse/opentracks/io/file/importer/KmzTrackImporter.java +++ b/src/main/java/de/dennisguse/opentracks/io/file/importer/KmzTrackImporter.java @@ -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; @@ -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); } } }