Skip to content

Commit

Permalink
support https URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
phraktle committed Jan 2, 2018
1 parent 9b22c9d commit b534482
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/main/java/com/phraktle/histodiff/HistoDiff.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b534482

Please sign in to comment.