현재 위치 - 회사기업대전 - 기업 정보 시스템 - 자바에서 IP 위치를 계산하는 방법

자바에서 IP 위치를 계산하는 방법

import?java.io.BufferedReader;

import?java.io.InputStreamReader;

import?java.net.URL;

import?java.net.URLConnection;

public?class?Test?{

public?static?void?main(String[]?args)?throws?Exception? {

//IP 쿼리를 위한 인터페이스: 88/?app=ip.get&ip=123.115.132.140&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json

BufferedReader?br?=?new?BufferedReader (new?InputStreamReader(System.in));

System.out.println("조회할 IP 주소를 입력하십시오:");

String?ip?=? br .readLine();

String?str_url?=?":88/?app=ip.get&ip="+ip+"&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json";

URL ?url?=?new?URL(str_url);

URLConnection?conn?=?url.openConnection();

BufferedReader?retun?=?new?BufferedReader(new ? InputStreamReader(conn.getInputStream()));

//여기에 반환되는 것은 JSON 형식이므로 직접 구문 분석하세요.

System.out.println(retun.readLine());

retun.close();

}

}

copyright 2024회사기업대전