forked from upstream-mirrors/OpenTracks
Cleanup: use InputStream.transferTo()
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user