Files
elink-online-common/src/main/java/com/eactive/eai/util/UrlUtil.java
T
Rinjae aacc1a389e init
2025-09-05 18:57:45 +09:00

28 lines
772 B
Java

package com.eactive.eai.util;
import java.net.MalformedURLException;
import java.net.URL;
public class UrlUtil {
public static String replaceIpAddress(String httpUrl, String newIp, String newPort) {
try {
URL url = new URL(httpUrl);
String host = url.getHost();
int port = url.getPort();
String newUrl = "";
if (port == -1) {
newUrl = httpUrl.replace(host, newIp + ":" + newPort);
} else {
newUrl = httpUrl.replace(host + ":" + port, newIp + ":" + newPort);
}
return newUrl;
} catch (MalformedURLException e) {
return httpUrl;
}
}
// public static void main(String[] args) throws Exception {
// System.out.println(
// replaceIpAddress("http://i-ada.postbank.go.kr:123/web/jmd/ONL/EAI/abcd", "192.168.0.1", "5555"));
// }
}