/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.utils;

import java.net.URI;

/**
 * @author 田平 create 2020年8月6日下午3:46:08
 */
public class UriUtil {

	public static final String getServerAddr(URI uri) {
		if (uri != null) {
			StringBuilder sb = new StringBuilder();
			sb.append(uri.getScheme()).append("://").append(uri.getHost());
			if (uri.getPort() > -1) {
				sb.append(":").append(uri.getPort());
			}
			sb.append(uri.getRawPath());
			return sb.toString();
		} else {
			return null;
		}
	}
}
