Source Code : Zip server socket

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Zip server socket

  

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import java.net.Socket;
 
class ZipSocket extends Socket {

    private InputStream in;
    private OutputStream out;

    public ZipSocket() { super(); }

    public ZipSocket(String host, int port) 
        throws IOException {
        super(host, port);
    }

    public InputStream getInputStream() 
        throws IOException {
        if (in == null) {
            in = new ZipInputStream(super.getInputStream());
        }
        return in;
    }

    public OutputStream getOutputStream() 
        throws IOException {
        if (out == null) {
            out = new ZipOutputStream(super.getOutputStream());
        }
        return out;
    }

   
    public synchronized void close() throws IOException {
        OutputStream o = getOutputStream();
        o.flush();
  super.close();
    }

}



import java.net.ServerSocket;
import java.net.Socket;
import java.io.IOException;

public class ZipServerSocket extends ServerSocket
{
  public ZipServerSocket(int port) throws IOException
  { 
  super(port);
  }

  public Socket accept() throws IOException
  { 
     Socket socket = new ZipSocket();
     implAccept(socket);
     return socket;
  }
}

   
    
  

Thank with us