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.
2 merge requests!28Version 3.17.0 Release,!26Add ZIP-archive support
Showing with 2 additions and 1 deletion
+2 -1
package de.hft.stuttgart.citydoctor2.zip;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
......@@ -33,7 +34,7 @@ public class CityGmlZipEntryFile implements AutoCloseable {
if (cgmlZipEntry.getFileSize() == -1L) {
if (zipEntry.getSize() == -1) {
long bytes = 0;
InputStream is = this.getInputStream();
InputStream is = new BufferedInputStream(this.getInputStream());
for (int i = is.read(); i != -1; i = is.read()) {
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