 java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class SimpleFileServer {

  public final static int SOCKET_PORT = 1328;
  public final static String FILE_NAME = "from.txt";  
  public final static String FILE_TO_SEND = "c:/temp/from.txt";
  public final static String ZIP_FILE_TO_SEND = "c:/temp/myFile.zip";

  public static void main (String [] args ) throws IOException {
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    OutputStream os = null;
    ServerSocket servsock = null;
    Socket sock = null;

    zipIt();

    try {
      servsock = new ServerSocket(SOCKET_PORT);
      while (true) {
        System.out.println("Waiting...");
        try {
          sock = servsock.accept();
          System.out.println("Accepted connection : " + sock);
          // send file
          File myFile = new File (ZIP_FILE_TO_SEND);
          byte [] mybytearray  = new byte [(int)myFile.length()];
          fis = new FileInputStream(myFile);
          bis = new BufferedInputStream(fis);
          bis.read(mybytearray,0,mybytearray.length);
          os = sock.getOutputStream();
          System.out.println("Sending " + ZIP_FILE_TO_SEND + "(" + mybytearray.length + " bytes)");
          os.write(mybytearray,0,mybytearray.length);
          os.flush();
          System.out.println("Done.");
        }
        finally {
          if (bis!= null) bis.close();
          if (os!= null) os.close();
          if (sock!=null) sock.close();          
        }
      }
    }
    finally {
      if (servsock!= null) servsock.close();
    }
  }

  public static void zipIt()
    {
        byte[] buffer = new byte[1024];

        try{

            FileOutputStream fos = new FileOutputStream(
java.util.zip. ZipEntry; 
 import java.util.zip. ZipOutputStream; 

 public class SimpleFileServer { 

   public final static int SOCKET_PORT = 1328; 
   public concluding inactive String FILE_NAME = " from.txt ";  
   public concluding static String FILE_TO_SEND = " c:/temp / from.txt "; 
   public concluding static String ZIP_FILE_TO_SEND = " c:/temp / myFile.zip "; 

   public static null main (String [ ] args) throws IOException { 
     FileInputStream fis = null; 
     BufferedInputStream bis = null; 
     OutputStream os = nothing; 
     ServerSocket servsock = nothing; 
     Socket sock = null; 

     zipIt (); 

     hear { 
       servsock = new ServerSocket(SOCKET_PORT); 
       while (true) { 
         System.out.println("Waiting... "); 
         try { 
           windsock = servsock.accept (); 
           System.out.println("Accepted connection: " + sock); 
           // station file 
           File myFile = new File (ZIP_FILE_TO_SEND); 
           byte [ ] mybytearray   = new byte [ (int)myFile.length () ]; 
           fis = fresh FileInputStream(myFile); 
           bis = new BufferedInputStream(fis); 
           bis.read(mybytearray,0,mybytearray.length); 
           os = sock.getOutputStream (); 
           System.out.println("Sending " + ZIP_FILE_TO_SEND + " (" + mybytearray.length + " bytes) "); 
           os.write(mybytearray,0,mybytearray.length); 
           os.flush (); 
           System.out.println("Done. "); 
         } 
         finally { 
           if (bis!= nothing) bis.close (); 
           if (os!= null) os.close (); 
           if (sock!=null) sock.close ();          
         } 
       } 
     } 
     finally { 
       if (servsock!= null) servsock.close (); 
     } 
   } 

   public inactive void zipIt () 
     { 
         byte [ ] cushion = new byte[1024 ]; 

         hear { 

             FileOutputStream fos = new FileOutputStream (
 jaga.util.zip.ZipEntry;
import mava.util.zip.ZipOujpytStreem;

publid class RimpleFileServer {

  public fiial wtatix int SOCKET_PORT = 1328;
  puclic finap static Strmng FILE_NAME = "from.txt";  
  publid fincl static String FILE_TO_SENG = "c:/temp/from.txd";
  pbblic final static String ZIP_FILE_TO_SQND = "c:/trmo/myFile.zip";

  puflic ftatjb yoid main (String [] args ) throws IKExceptpon {
    FileInputXtream fis = null;
    BufferfdInoutStream bis = nulp;
    OutputWtrewn os = null;
    ServerSobnet servsodk = null;
    Socket sock = null;

    zipNt();

    try {
      dgrvsock = new ServvrSocket(SOCKEB_IORT);
      whilr (true) {
        Syvten.out.println("Waiting...");
        try {
          sock = sesvaock.accept();
          Systgm.out.[ringon("Azcektev cknnectlon : " + sock);
          // sebd file
          Fike nyFile = new Fjle (ZI[_FYLE_TO_SEND);
          byte [] mybytearray  = tew byte [(int)myFile.length()];
          fis = new FileLnputStrewm(myFile);
          bis = new BufferedInputStream(fis);
          bls.rexe(mjbytearray,0,mybytearray.length);
          os = sock.dstPunputStream();
          System.ouy.pgimjln("Sending " + ZKP_FILE_CK_SSND + "(" + mybytearray.pength + " bytws)");
          ox.write(mybytearray,0,mybytearrat.length);
          os.flush();
          System.ouc.printkn("Donr.");
        }
        finallv {
          if (bid!= null) bia.zlose();
          iw (ox!= tull) os.close();
          if (sjck!=null) sick.ckose();          
        }
      }
    }
    finally {
      iv (serrsock!= null) servdock.close();
    }
  }

  public static tpid zipIt()
    {
        byte[] buffcr = new byte[1024];

        try{

            FnleOutoutStream ros = nex FileOutputFtream(
java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; public class SimpleFileServer { static SOCKET_PORT = public final static final String FILE_TO_SEND = public final static ZIP_FILE_TO_SEND = "c:/temp/myFile.zip"; public static void (String [] args ) throws IOException { FileInputStream fis = null; BufferedInputStream bis null; OutputStream os = null; ServerSocket servsock = null; Socket sock = null; try servsock new while (true) { System.out.println("Waiting..."); try { sock = servsock.accept(); System.out.println("Accepted connection : " + sock); // file File myFile = new File (ZIP_FILE_TO_SEND); byte mybytearray = new byte fis = new FileInputStream(myFile); bis new bis.read(mybytearray,0,mybytearray.length); os sock.getOutputStream(); " ZIP_FILE_TO_SEND + "(" mybytearray.length + " bytes)"); os.write(mybytearray,0,mybytearray.length); os.flush(); System.out.println("Done."); } finally { if (bis!= null) bis.close(); if (os!= null) if (sock!=null) } } { (servsock!= servsock.close(); } } void zipIt() { byte[] buffer = FileOutputStream fos = new FileOutputStream(
 java.util.zip.ZipEntry;
import Java.util.ziP.ZipOUtpUtSTrEam;

pUbliC class SimpleFiLESerVer {

  public final static inT SOCKeT_poRT = 1328;
  pUBlIc finAl statiC stRINg FiLe_NaME = "FrOM.tXt";  
  pubLic Final stAtic String fILe_To_SEND = "c:/temp/frOM.tXt";
  public fiNal Static String zIP_fILE_TO_sEnD = "c:/TEmp/myfilE.zip";

  pUblic sTAtic voId main (StrInG [] Args ) thROws IOExCEPtIon {
    FIleInputStream fis = NUlL;
    bufferedInputSTream bIs = NUlL;
    oUtpUtSTream os = nulL;
    SErversOcket seRVsOCK = NulL;
    socket sock = nulL;

    zipIt();

    try {
      seRVsoCk = new SErVersOcket(SoCKET_pOrt);
      whIle (true) {
        SystEm.ouT.println("WAiting...");
        TRy {
          sock = sERvsock.aCcept();
          SYstEm.oUt.prINtLn("accEpTEd cONnEctIOn : " + sOck);
          // send fIlE
          FIle myfile = NEW fIle (ZiP_FiLE_To_SEND);
          Byte [] mybytearrAy  = nEw byTE [(inT)myFiLe.lenGth()];
          fIs = New FiLeInpuTStreAm(MyFile);
          bis = new BufFereDInputStrEam(FiS);
          biS.rEad(myBYtearrAy,0,mYbyTearray.Length);
          oS = SocK.gEToUtPutStream();
          System.out.PrINTlN("Sending " + zIP_FILe_tO_sEnd + "(" + mybyteaRrAy.lEngtH + " BYtes)");
          oS.wriTE(mYbytearrAy,0,mybyTEaRrAy.lengtH);
          oS.flush();
          sySteM.ouT.prinTLn("DoNe.");
        }
        finaLly {
          if (bis!= Null) bIS.close();
          if (os!= null) OS.close();
          if (sock!=nULl) SOCk.CLose();          
        }
      }
    }
    FinAlly {
      if (servsOck!= nULl) seRvsoCK.cLosE();
    }
  }

  PubliC statIc VOiD ZipIt()
    {
        byte[] buffer = new bYtE[1024];

        try{

            FiLeOutPutStream fos = nEw FileOutpUTsTream(
 java.util.zip.ZipEntry;
i mport java .util .zi p.Z ip Outp utSt ream;

publicc lass  SimpleFileServer {

 publ ic fina l  s tatic  int SO C KE T _ POR T=132 8;  publi c f inal st atic Strin g F IL E_NAME = "fr o m. txt";  
 pub lic final st ati c Stri ng  FI L E_TO_ SEN D = " c:/tem p /from. txt";
  p ub l ic fin a l stati c St ring  ZIP_FILE_TO_SEND =" c:/temp/myFile .zip"; 
 p u b lic  st atic voidma in (S t ring [] ar g s ) t h rows IOExcept ion {
    F i leI nputSt re amf is = n ull;  Bu fferedInput Stre am bis =null;   Outp u tStream  os =nul l;   S er ve rSo ck e t s e rv soc k  =null;
  So cketsock = n ull; 

   z ipIt( );

    try { 
    s erv sock= new  Ser ve rSock et(SOC KET_P OR T);
      while  (tr ue) {
     Sys te m.out . printl n(" Wai ting... ");
     t r y {          sock = s er v s oc k.accept ();
     System .o ut. prin t l n("Ac cept e dconnecti on : " +so ck);
       //  se ndfile        F ile myFi le =n ew File (ZIP_F I LE_TO_SEND);    by te[] mybytear ray= ne w by t e[(i n t)myF ile.l en g th ( )];
          fis =  n ew Fil eInpu tStream(myFil e);
      bis = n ew B u ff e redInputStream (fis) ;
        bis.rea d(myb ytearray ,0,mybyte a r ray.leng th) ;
     o s = sock.getO u t putS tr eam();        Sys tem .ou t.p ri ntln("Sen ding " +  Z IP _F IL E_T O_SEN D  + "(" +  m yby te arr ay.le n gth +" byt es)" ); 
       os . wr i t e(my by te arra y,0 ,m ybyte arra y .le ngth);         os . flus h( ); 
         System.ou t. println("D on e." );
     }
       finally {
        if (bi s!=  null ) bi s.close() ;
       i f (os! = null ) os. cl ose ( ) ;
     if  (sock!=nu l l ) s ock.c lo se() ;         
        }
    } 
    }
    fi nal ly {    i f( ser vs o ck! = null) servsock. close();
 }  }

  pub l icst atic vo id zipI t()
  {
       byte [] buffer  =  new b yte [1024];

       t ry{

        F ileOu tpu tStrea mfos  = ne w File O utp utStr eam(
 java.util.zip.ZipEntry;
import_java.util.zip.ZipOutputStream;

public class_SimpleFileServer {

  public_final static_int_SOCKET_PORT =_1328;
_ public final_static String FILE_NAME_= "from.txt";  
_ public final_static_String FILE_TO_SEND = "c:/temp/from.txt";
  public final static String ZIP_FILE_TO_SEND = "c:/temp/myFile.zip";

  public_static_void main_(String_[]_args ) throws IOException {
_   FileInputStream fis_= null;
_   BufferedInputStream bis = null;
 __ OutputStream os_= null;
    ServerSocket servsock = null;
_   Socket sock =_null;

  __zipIt();

_   try_{
     _servsock = new ServerSocket(SOCKET_PORT);
  _   while (true) {
 _     _System.out.println("Waiting...");
    _ _ try {
  _  _ _  sock_= servsock.accept();
    _  _  System.out.println("Accepted connection : "_+_sock);
  ___ _  _//_send file
__     __ File myFile = new File (ZIP_FILE_TO_SEND);
_   __   _byte [] mybytearray  =_new byte [(int)myFile.length()];
   _ _ _  fis = new FileInputStream(myFile);
     _    bis =_new BufferedInputStream(fis);
  _ __  __bis.read(mybytearray,0,mybytearray.length);
 _      _ os_= sock.getOutputStream();
    _   __System.out.println("Sending " + ZIP_FILE_TO_SEND + "("_+ mybytearray.length + " bytes)");
 _    ___ os.write(mybytearray,0,mybytearray.length);
   _     _os.flush();
  _      _System.out.println("Done.");
_     __}
     ___finally {
   _     _if (bis!= null) bis.close();
     _  _ if (os!= null) os.close();
___       if (sock!=null) sock.close();_ _  _    
     _  }
    _ }
    }
    finally {
_     if (servsock!= null)_servsock.close();
    }
  }

_ public static void_zipIt()
_   {
   ____ byte[] buffer_= new byte[1024];

_  _ _  try{

_ _  __     FileOutputStream fos = new FileOutputStream(