Java tutorial
//package com.java2s; public class Main { public static String[] getIpAndPort(String ip) { if (ip == null || ip.trim().length() < 4) { return null; } String[] strs = null; int index = ip.indexOf(":"); if (index != -1) { strs = ip.split(":"); } else { strs = new String[] { ip, "80" }; } return strs; } }