NetUtil { public static byte[] download(String url) throws IOException { return download(new URL(url)); } private  NetUtil(); static boolean checkPort(String host, int port); static byte[] download(String url); static void download(String url, File file); static byte[] download(URL url); static void download(URL url, File file); static Optional<String> serviceName(int port);  }
@Test @DisplayName("Download a small file into memory") void download_1() throws IOException { byte[] file = download("https: assertNotNull(file); assertTrue(file.length > 0); }
@Test @DisplayName("Download a small file to the filesystem") void download_2(@TempDir Path temp) throws IOException { download("https: temp.resolve("test.txt").toFile()); assertTrue(Files.exists(temp.resolve("test.txt"))); assertTrue(Files.size(temp.resolve("test.txt")) > 0); }
@Test @DisplayName("Try to download a file that is too big for this method") void download_3() throws IOException { assertThrows(IllegalArgumentException.class, () -> download("http: }