| | |
| | | import kr.wisestone.owl.vo.CompanyFieldVo; |
| | | import kr.wisestone.owl.vo.IspFieldVo; |
| | | import org.apache.commons.lang3.ArrayUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | import java.lang.reflect.Method; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.regex.Pattern; |
| | | |
| | | public class ConvertUtil { |
| | | static final Logger LOGGER = LoggerFactory.getLogger(ConvertUtil.class); |
| | |
| | | */ |
| | | public static long ipToLong(String ipAddress) { |
| | | long result = 0; |
| | | String[] ipAddressArr = ipAddress.split("\\."); |
| | | String reg = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" + |
| | | ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"; |
| | | if (!StringUtils.isEmpty(ipAddress) && !Pattern.matches(reg, ipAddress)) { |
| | | return result; |
| | | } else { |
| | | String[] ipAddressArr = ipAddress.split("\\."); |
| | | |
| | | for (int i=0; i<ipAddressArr.length; i++) { |
| | | result += Integer.parseInt(ipAddressArr[i]) * Math.pow(256, 3-i); |
| | | for (int i=0; i<ipAddressArr.length; i++) { |
| | | result += Integer.parseInt(ipAddressArr[i]) * Math.pow(256, 3-i); |
| | | } |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |