code: public static Proxy parseProxy(String proxy_entry){
  
        String proxy_host;
        int proxy_port = 1080;
        String proxy_user = null;
        String proxy_password = null;
        Proxy proxy;
  
        java.util.StringTokenizer st = new java.util.StringTokenizer(
                                           proxy_entry,":");
        if(st.countTokens() < 1) return null;
  
        proxy_host = st.nextToken();
        if(st.hasMoreTokens())
           try{
             proxy_port = Integer.parseInt(st.nextToken().trim());
           }catch(NumberFormatException nfe){}
  
        if(st.hasMoreTokens())
           proxy_user = st.nextToken();
  
        if(st.hasMoreTokens())
           proxy_password = st.nextToken();
  
        try{
           if(proxy_user == null)
             proxy = new Socks5Proxy(proxy_host,proxy_port);
           else if(proxy_password == null)
             proxy = new Socks4Proxy(proxy_host,proxy_port,proxy_user);
           else{
             proxy = new Socks5Proxy(proxy_host,proxy_port);
             UserPasswordAuthentication upa = new UserPasswordAuthentication(
                                              proxy_user, proxy_password);
  
             ((Socks5Proxy)proxy).setAuthenticationMethod(UserPasswordAuthentication.METHOD_ID,upa);
           }
        }catch(UnknownHostException uhe){
           return null;
        }
  
        return proxy;
     }
docs: Parses strings in the form: host[:port:user:password], and creates
  proxy from information obtained from parsing.
  <p>
  Defaults: port = 1080.<br>
  If user specified but not password, creates Socks4Proxy, if user
  not specified creates Socks5Proxy, if both user and password are
  speciefied creates Socks5Proxy with user/password authentication.
  @param proxy_entry String in the form host[:port:user:password]
  @return Proxy created from the string, null if entry was somehow
  invalid(host unknown for example, or empty string)