Commit 0a152a4c authored by Riegel's avatar Riegel
Browse files

Refactor: Reduce hard drive usage for getFileSize()

Use a BufferedInputStream for counting the bytes of a ZipEntry to reduce
the number of read operations on the hard drive.
parent 4496706d
package de.hft.stuttgart.citydoctor2.zip; package de.hft.stuttgart.citydoctor2.zip;
import java.io.BufferedInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
...@@ -33,7 +34,7 @@ public class CityGmlZipEntryFile implements AutoCloseable { ...@@ -33,7 +34,7 @@ public class CityGmlZipEntryFile implements AutoCloseable {
if (cgmlZipEntry.getFileSize() == -1L) { if (cgmlZipEntry.getFileSize() == -1L) {
if (zipEntry.getSize() == -1) { if (zipEntry.getSize() == -1) {
long bytes = 0; long bytes = 0;
InputStream is = this.getInputStream(); InputStream is = new BufferedInputStream(this.getInputStream());
for (int i = is.read(); i != -1; i = is.read()) { for (int i = is.read(); i != -1; i = is.read()) {
bytes++; bytes++;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment