Cleanup: use InputStream.transferTo()

This commit is contained in:
Dennis Guse
2023-11-24 07:11:22 +01:00
parent 25d4daa295
commit 8b7063d18b
@@ -228,7 +228,6 @@ public class KmzTrackImporter {
* @param trackId the track's id which image belongs to. * @param trackId the track's id which image belongs to.
* @param fileName the file name * @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 { private void readAndSaveImageFile(ZipInputStream zipInputStream, Track.Id trackId, String fileName) throws IOException {
if (trackId == null || "".equals(fileName)) { if (trackId == null || "".equals(fileName)) {
return; return;
@@ -238,11 +237,7 @@ public class KmzTrackImporter {
File file = new File(dir, fileName); File file = new File(dir, fileName);
try (FileOutputStream fileOutputStream = new FileOutputStream(file)) { try (FileOutputStream fileOutputStream = new FileOutputStream(file)) {
byte[] buffer = new byte[4096]; zipInputStream.transferTo(fileOutputStream);
int count;
while ((count = zipInputStream.read(buffer)) != -1) {
fileOutputStream.write(buffer, 0, count);
}
} }
} }
} }