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))) {
System.out.println(mmdb);
Files.copy(
new URL(mmdb).openStream(),
Paths.get(zipFilename));
try (GZIPInputStream gis = new GZIPInputStream(new FileInputStream(Path.of(zipFilename).toFile()))) {
Files.copy(gis, Path.of(dbFileName));
}
}

SpringApplication.run(Application.class, args);
}

No comments:

apple iphone 16 return in UK Glasgow

 After I saw that WhatsApp desktop is not working(I tried 2 different laptops, uninstalled or resetting the app but did not work) and uBlock...