User Tools

Site Tools


mirnshi:a_java_class_to_get_a_compressed_file_from_the_server

A java class to get a compressed file from the server

Some guys often ask me to help them to get some files from the server, such as tomcat log. Everytime I must open ftp client to connect the server, download these file. The lazy man need a smart way to do this job. Now they can help themselves.

 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.zip.*;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 public class ZGet {
     public void get(HttpServletRequest request, HttpServletResponse response, String filename) {
         try {
             // String fname = request.getParameter("xpath");
             fname = filename;
             File f = new File(fname);
             if (f.canRead()) {
                 response.setContentType("application/x-gzip");
                 response.setHeader("Location", f.getName());  
                 response.setHeader("Content-Disposition", "attachment; filename=" + f.getName() + ".gz");
                 get(new FileInputStream(filename), response.getOutputStream());
                 response.getOutputStream().flush();
                 response.getOutputStream().close();
              }
          } catch (Exception e) {
              // TODO Auto-generated catch block
              //e.printStackTrace();
          }  
      }
      private void get(InputStream in, OutputStream out) throws IOException {
          if (in == null || out == null) {
              return;
          }
          byte[] buffer = new byte[1024];
          int i = -1;
          GZIPOutputStream gzip = new GZIPOutputStream(out);
          while ((i = in.read(buffer)) != -1) {
              gzip.write(buffer, 0, i);
          }
          gzip.close();
      }
  }

Discussion

, AXBLMHFZYBu, 2012/01/06 02:37

This is a rellay intelligent way to answer the question.

, 2019/03/27 01:58

http://www.katespade-outlet.us http://www.nikeflipflops.org http://www.nobisjackets.us.com http://www.ubiqshoes.us http://www.baltimoreoriolesjerseys.us http://www.moncler-outlet.us.com http://www.clevelandbrownsjerseys.us http://www.coachoutletcoachs.us.com http://www.hydroflask.us.com http://www.jordans-fusion.com http://www.christianlouboutinshoes.org http://www.coach-factoryoutlets.us.com http://www.ultraboosts.us.com http://www.fitflopsoutletsale.com http://www.canada-gooseoutletstore.name http://www.superdry.me.uk http://www.cheapjordansoutlet.in.net http://www.cheapnba-jerseys.us.com http://www.mbtshoesuk.org.uk http://www.coach-factoryoutletstore.us.com http://www.coachoutlet-canada.ca http://www.ralphlaurenoutlet.in.net http://www.edhardyoutlet.us http://www.jimmychoo.us.com http://www.hermesoutlets.us.com http://www.northfacejacket.us.com http://www.fjallravenoutlet.us.com http://www.louboutinoutlets.us.com http://www.coloradorockiesjerseys.us http://www.kendrascottjewelrys.com http://www.ralphlaurenpolo.us.org http://www.redbottomsshoes.us.com http://www.maujimsunglasses.com http://www.newenglandpatriotsjerseys.us.com http://www.texansjerseys.us http://www.balenciagasneaker.us.com http://www.monclersitoufficiale.it http://www.airhuaracheuk.org.uk http://www.cheapmlbjerseys.net http://www.canadagoosefactory.us http://www.converse-uk.me.uk http://www.christian-louboutins.fr http://www.coachoutlet-online.eu.com http://www.outletcoachoutlets.us.com http://www.truereligionjeans-sale.us.com http://www.lacosteoutlet.us.org http://www.greenbaypackersjersey.us http://www.prada.us.org http://www.pandorajewelrysoutlet.us.com http://www.cheapraybansunglasses.net.co http://www.airjordanpaschere.fr http://www.kate-spadeoutlet.us.com http://www.christian-louboutinoutlet.us.com http://www.rosherun.org http://www.airmax2017.org http://www.ralphlaurenpolo.in.net http://www.coachoutletstores.eu.com http://www.uggbootssale.ca http://www.northfaceoutlet.us.com http://www.edhardyclothing.us.com http://www.chelseajerseys.us http://www.valentinooutletstore.us.com http://www.philadelphiaphilliesjerseys.us http://www.nikeoutletonline.us.com http://www.coachoutlet-clearance.us.com http://www.detroitlionsjerseys.us http://www.converseshoesoutlet.us.com http://www.coachoutletstores.com.co http://www.barcelonajersey.us http://www.supremeclothinguk.co.uk http://www.davidyurmanjewelry.us.com http://www.seattleseahawksjersey.us http://www.nike-outletstore.us.com http://www.airjordan.us.org http://www.michaelkorsoutlet-clearance.us.org http://www.christianlouboutin-outlet.in.net http://www.mcm-outlets.us.com http://www.ferragamoshoes.us http://www.celine-outlet.us.com http://www.converseshoes.us.com http://www.ralphlauren-poloshirt.org.uk http://www.moncleroutlets.us.org http://www.polo-outlets.com.co http://www.coachoutletclearancesale.us.com http://www.coachhandbagsclearance.us.com http://www.snapbackhats.us.com http://www.minnesotavikingsjersey.us http://www.coachoutletclearance.us.com http://www.torontobluejaysjerseys.us http://www.kobeshoes.us.com http://www.airmax97.org http://www.adadassuperstar.com http://www.us-coatsjackets.com http://www.christianlouboutinoff.us http://www.oaklandraidersjerseys.us http://www.nike-shoes.us.org http://www.canadasgooseoutlet.us.com http://www.nikehyperdunks.com QQQ

, http://theprettyguineapig.com/amoxicillin/, 2019/04/19 20:05

http://theprettyguineapig.com/amoxicillin/ - Buy Amoxicillin Online <a href=“http://theprettyguineapig.com/amoxicillin/”>Amoxicillin 500 Mg</a> bux.ltfi.wiki.freecode.com.cn.lxs.js http://theprettyguineapig.com/amoxicillin/

, http://theprettyguineapig.com/amoxicillin/, 2019/04/19 21:22

http://theprettyguineapig.com/amoxicillin/ - Amoxicillin 500mg Capsules <a href=“http://theprettyguineapig.com/amoxicillin/”>Amoxicillin 500mg Capsules</a> bmr.nmml.wiki.freecode.com.cn.ixo.vf http://theprettyguineapig.com/amoxicillin/

, 2019/10/10 11:13

Garage, 26, is one <a href=http://www.kdshoes.us.com>kd shoes</a> of the largest child, dell - garage in 2002, the dad announced over 07 years of career, finally handed over 40. 2% on threes report card. From a quite young age, Stephen about the shooting learned how to shoot for the feet of the get better at, when dad refused to consider him to the hornets teaching, Stephen will be pursed mouth, not because can't visit those big-name players, the old you happen to be, but because he also desire to be with my dad, to practice his shot.

At age 9, garage is of her own <a href=http://www.stephencurryshoes.us>stephen curry shoes</a> amateur league teams associated with players, only if the coach must outside shot collapse for the opponent's zone will always be sent. Recalled the yourself, garage proudly said: “when My spouse and i was a defense gurus, all start from presently there. ”

To go here we are at <a href=http://www.curryshoes.us.com>curry shoes</a> the original text, if your garage near the baseball in midfield, people tend to overlook the most important thing: pool soccer ball skills. Sonya, thanks in order to his mother, then any 5 feet tall 3, cordial and some stubborn woman again as well, she was in secondary school played point guard, looking towards the volleyball after into the campus of Virginia technological, and meet the car port there's father. “If I dribble towards coast, I have to pick to shoot or go, it's my limit. “Dell mentioned, “people started for Stephen impression is all they can beautiful posture hit photographs, but before becoming any striker, he already was an improved control player, people have a tendency to ignore it. After their dribble shot, is I the most wonderful moments. Thanks to his or her mother. ”.

Tag: <a href=http://www.kyrieirvingshoes.us.com>kyrie irving shoes</a> <a href=http://www.nikehuarache.org>nike huarache</a> <a href=http://www.nikecr7.com>Nike CR7</a> <a href=http://www.kobe-10.org>kobe 10</a> <a href=http://www.kyrieirvingjersey.com>kyrie irving jersey</a> <a href=http://www.pumafenty.us.com>puma fenty</a> <a href=http://www.adidasyeezyoutlet.us.com>adidas yeezy</a> <a href=http://www.air-jordan-shoes.us.com>air jordan shoes</a> <a href=http://www.michaeljordanshoes.us>michael jordan shoes</a> <a href=http://www.jordanretro.us.com>jordan retro</a> <a href=http://www.kobe11.org>kobe 11</a> <a href=http://www.kyrie4halloween.com>kyrie 4 halloween</a> <a href=http://www.airjordan32.us>air jordan 32</a> <a href=http://www.johnwallshoes.us.com>john wall shoes</a> <a href=http://www.kobe--shoes.com>kobe shoes</a> <a href=http://www.kobebryantjersey.us>kobe bryant jersey</a> <a href=http://www.porschedesignshoesonline.com>adidas shoes</a> <a href=http://www.birkenstock-sandals.us>birkenstock</a> <a href=http://www.kyrie-4.com>kyrie 4</a> <a href=http://www.adidaszxflux.us.com>adidas zx flux</a> <a href=http://www.adidasnmdshoes.us.com>adidas nmd shoes</a> <a href=http://www.kyrie2.us>kyrie 2</a> <a href=http://www.nikevapormaxshoes.us.com>nike vapormax shoes</a> <a href=http://www.nikezoomvaporflyelite.us>nike zoom vaporfly elite</a> <a href=http://www.adidasultraboost4.com>ultra boost 4.0</a> <a href=http://www.nikeepicreactflyknit.us>nike epic react</a> <a href=http://www.adidasboostyeezy.us.com>yeezy boost</a> <a href=http://www.underarmourshoes.us.com>under armour shoes</a> <a href=http://www.nikesoccercleats.us.com>Nike Soccer Cleats</a> <a href=http://www.nike-mercurial.us>nike mercurial</a> <a href=http://www.lebronsoldier11.org>soldier 11</a> <a href=http://www.lebron-14.us>lebron 14 shoes</a> <a href=http://www.kd-11.us>kd 11</a> <a href=http://www.kyrie4.us.com>kyrie 4</a> <a href=http://www.nikehyperdunk.us.com>nike hyperdunk</a> <a href=http://www.kyrie3.us>kyrie 3</a> <a href=http://www.kd-10.com>kd 10</a> <a href=http://www.stephencurryjersey.us>stephen curry jersey</a> <a href=http://www.kyrie-irvingshoes.com>nike kyrie shoes</a> <a href=http://www.lebron-shoes.us>lebron james shoes</a> <a href=http://www.pumasuede.us.com>puma suede</a> <a href=http://www.kyrie4.com>kyrie 4</a> <a href=http://www.airmax270.us>air max 270</a> <a href=http://www.kyrie-3.com>kyrie 3</a> <a href=http://www.nikeairmax97.us.com>nike air max 97</a> <a href=http://www.curry2.com>curry 2</a> <a href=http://www.kdshoes.us.com>kevin durant shoes</a> <a href=http://www.lebron-james-shoes.us.com>lebron james shoes</a> <a href=http://www.kyrie4halloween.us>kyrie 4 halloween</a> <a href=http://www.ultraboostshoes.us.com>ultra boost shoes</a> <a href=http://www.nikeairmoreuptempo.us.com>nike air more uptempo</a> <a href=http://www.kyrie3shoes.com>kyrie shoes 3</a> <a href=http://www.lebronshoes.us.com>lebron shoes</a> <a href=http://www.stephencurry-shoes.com>stephen curry shoes</a> <a href=http://www.kyrieirvingshoes.us>kyrie irving shoes</a> <a href=http://www.ultraboostadidas.us.com>adidas ultra boost uncaged</a> <a href=http://www.curry-5.us>curry 5</a> <a href=http://www.nikevapormax.us.com>nike air vapormax</a> <a href=http://www.nikelebronjamesshoes.us.com>Nike Lebron James Shoes</a> <a href=http://www.kd11.org>kd 11 shoes</a> <a href=http://www.kevindurantjersey.us.com>kevin durant jersey</a> <a href=http://www.curry-5.us>curry 5</a> <a href=http://www.lebronsoldier10.us>lebron soldier 10</a> <a href=http://www.pumafentyslides.us>puma fenty slides</a> <a href=http://www.nikeairpresto.us.com>nike air presto</a> <a href=http://www.pumafenty.us>puma fenty</a> <a href=http://www.nikezoomvaporfly.us.com>nike zoom vaporfly</a> <a href=http://www.kd-shoes.org>kd shoes</a> <a href=http://www.calvinklein-underwear.us.com>calvin klein</a> <a href=http://www.kyrie2shoes.com>kyrie 2 shoes</a> <a href=http://www.kyrie1.us>kyrie 1</a> <a href=http://www.curry-5.us.com>curry 5</a> <a href=http://www.yeezy--boost.us.com>yeezy boost</a> <a href=http://www.kyrie--4.com>kyrie 4</a> <a href=http://www.vanssk8hi.us>vans sk8 hi</a> <a href=http://www.pumarihannacreepers.us>puma rihanna creepers</a> <a href=http://www.yeezyshoes.us.com>yeezy shoes</a> <a href=http://www.nikepg2.us>nike pg 2</a> <a href=http://www.mizunoshoes.us.com>mizuno running shoes</a> <a href=http://www.asicsgelkayano23.com>asics gel kayano 23</a> <a href=http://www.adidassoccercleats.us.com>adidas soccer cleats</a> <a href=http://www.lebronsoldier10.us.com>lebron soldier 10</a> <a href=http://www.pgshoes.com>paul george shoes</a> <a href=http://www.lebron-14.us>lebron 14 shoes</a> <a href=http://www.kobebryantshoes.us.com>nike kobe shoes</a> <a href=http://www.nikesockracer.com>nike sock racer</a>

Enter your comment. Wiki syntax is allowed:
 
mirnshi/a_java_class_to_get_a_compressed_file_from_the_server.txt · Last modified: 2009/12/19 05:22 by mirnshi