From b534482e01a55e3becc05a6dcf0e229bdde75112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Szathm=C3=A1ry?= Date: Tue, 2 Jan 2018 10:10:04 +0100 Subject: [PATCH] support https URLs --- .../java/com/phraktle/histodiff/HistoDiff.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/phraktle/histodiff/HistoDiff.java b/src/main/java/com/phraktle/histodiff/HistoDiff.java index 185b20e..5034693 100644 --- a/src/main/java/com/phraktle/histodiff/HistoDiff.java +++ b/src/main/java/com/phraktle/histodiff/HistoDiff.java @@ -37,16 +37,17 @@ public static void main(String[] args) throws IOException { } static File parseFileArg(String[] args, int idx) throws IOException { - if (args[idx].startsWith("http://")) { - File targetFile = File.createTempFile("histodiff-temp-file-", ".tmp"); - targetFile.deleteOnExit(); - URL httpTarget = new URL(args[idx]); - try (InputStream in = httpTarget.openStream()) { - Files.copy(in, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + String location = args[idx]; + if (location.startsWith("http://") || location.startsWith("https://")) { + File file = File.createTempFile("histodiff", ".tmp"); + file.deleteOnExit(); + URL url = new URL(location); + try (InputStream in = url.openStream()) { + Files.copy(in, file.toPath(), StandardCopyOption.REPLACE_EXISTING); } - return targetFile; + return file; } else { - return new File(args[idx]); + return new File(location); } }