BAEL-4856 Remove BinaryFileDownloadApplication.java and use correct indentation
This commit is contained in:
parent
9e369a8258
commit
91dfad8bec
|
@ -1,26 +0,0 @@
|
||||||
package com.baeldung.okhttp.download;
|
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
|
|
||||||
public class BinaryFileDownloadApplication {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
String url = args[0];
|
|
||||||
String file = args[1];
|
|
||||||
try (BinaryFileDownloader downloader = new BinaryFileDownloader(new OkHttpClient(),
|
|
||||||
new BinaryFileWriter(new FileOutputStream(file)))) {
|
|
||||||
long downloadSize = downloader.download(url);
|
|
||||||
double downloadSizeInMB = convertToMB(downloadSize);
|
|
||||||
System.out.printf("Successfully downloaded file %s from %s. Total size %.2fMB%n", file, url, downloadSizeInMB);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
System.err.printf("Could not download file %s from %s. %nError: %s%n", file, url, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double convertToMB(double downloadSize) {
|
|
||||||
return downloadSize / (1024.0 * 1024.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -68,13 +68,7 @@ public class BinaryFileDownloaderUnitTest {
|
||||||
@NotNull
|
@NotNull
|
||||||
private Response createResponse(String url, ResponseBody body) {
|
private Response createResponse(String url, ResponseBody body) {
|
||||||
Request request = new Request.Builder().url(url).build();
|
Request request = new Request.Builder().url(url).build();
|
||||||
return new Response.Builder()
|
return new Response.Builder().code(200).request(request).protocol(Protocol.HTTP_2).message("Message").body(body).build();
|
||||||
.code(200)
|
|
||||||
.request(request)
|
|
||||||
.protocol(Protocol.HTTP_2)
|
|
||||||
.message("Message")
|
|
||||||
.body(body)
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue