Thursday, June 10, 2021

download zipped/gz file and unzip and use in java

 Example code for downloading a zipped file and unzipping in java

public static void main(String[] args) throws Exception {
String mmdb = "https://someaddress/somefile.gz";
String zipFilename = "somefile.gz";
if (!Files.exists(Path.of(zipFilename))) {
new URL(mmdb).openStream(),
try (GZIPInputStream gis = new GZIPInputStream(new FileInputStream(Path.of(zipFilename).toFile()))) {
Files.copy(gis, Path.of(dbFileName));
}, args);

No comments:

odd string diff Beats 19.92% of users with Java   class Solution { public String oddString ( S...