nslookup 구현
2024. 8. 23. 23:33ㆍJava
참조
https://a-half-human-half-developer.tistory.com/108
[Java] nslookup
자바로 nslookup을 구현할 수 있다. public void nslookup(String domain) { InetAddress[] inetaddr = null; try { inetaddr = InetAddress.getAllByName(domain); } catch(Exception e) { e.printStackTrace(); } for (InetAddress inetAddress : inetaddr) { Sys
blog.develop-gyuri.cloud
[Java/자바] List와 String(문자열, 배열)을 서로 변환하는 법
List ↔ String List를 String으로 간단히 변환 join() 메서드 활용List list = new ArrayList();String answer = String.join(",",list); String을 List로 변환split() 메서드 활용String s = "sample";String[] strArr = s.split(""); // [s, a,
hstory0208.tistory.com
public static String[] nslookup(String data) throws Exception {
InetAddress[] inetAddresses = InetAddress.getAllByName(data);
List<String> ipList = new ArrayList<String>();
for(InetAddress inetAddress : inetAddresses) {
ipList.add(inetAddress.getHostAddress());
}
return ipList.toArray(new String[ipList.size()]);
}
'Java' 카테고리의 다른 글
String[]을 List로 전환 (0) | 2024.09.08 |
---|---|
String 배열에 요소 추가 (0) | 2024.08.28 |
Class 정보 가져오기 (0) | 2024.07.27 |
request 객체 정보 조회 (0) | 2024.07.27 |
java Tip (0) | 2022.02.02 |