Code:
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Impulser
 * @version 1.0
 * 
 */
public class Main {

	private static List<Integer> ports = new ArrayList<Integer>();
	private static String host = "rune-server.org";
	
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		for (int port = 1; port <= 80; port++)
			try {
				Socket socket = new Socket();
				socket.bind(null);
				socket.connect(new InetSocketAddress(host, port), 140);
				socket.close();
				System.out.println("Port: "+port);
				ports.add(port);
			} catch (IOException ex) {
		}
		int portList = ports.size();
		System.out.println("Total Ports: "+portList);
	}

}
There are other ways to do this like with multi-threads and have a thread scan ports 1-2000 then another do 2001-4000 to make it faster but here is the good, fast and basic way using a timeout feature so it doesn't waste time checking.