Posts

Showing posts from June, 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) ; }