mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
parent
23e161c2c2
commit
1a65058a26
1 changed files with 12 additions and 6 deletions
|
@ -370,9 +370,14 @@ public class Main {
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
long bytesSoFar = 0;
|
long bytesSoFar = 0;
|
||||||
byte[] buffer = new byte[100_000];
|
byte[] buffer = new byte[100_000];
|
||||||
|
boolean hasTerminal = System.console() != null;
|
||||||
|
if (! hasTerminal) {
|
||||||
|
log2(1, "\rDownloading " + url);
|
||||||
|
}
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
outputStream.write(buffer, 0, bytesRead);
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
bytesSoFar += bytesRead;
|
bytesSoFar += bytesRead;
|
||||||
|
if (hasTerminal) {
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
if (contentLength > 0) {
|
if (contentLength > 0) {
|
||||||
float percent = bytesSoFar * 100 / contentLength;
|
float percent = bytesSoFar * 100 / contentLength;
|
||||||
|
@ -382,6 +387,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
log2(1, "\n");
|
log2(1, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue