package
com.ljn.base;
import
java.io.BufferedReader;
import
java.io.IOException;
import
java.io.InputStreamReader;
import
java.net.MalformedURLException;
import
java.net.URL;
import
java.net.URLConnection;
/**
* @author YK
* @date:2017-03-29 上午9:54
*/
public
class
HttpJSONTest {
/**
* @param args
*/
public
static
void
main(String[] args) {
String url =
"https://tcc.taobao.com/cc/json/mobile_tel_segment.htm?tel=15689736537"
;
String json = loadJSON(url);
System.out.println(json);
}
public
static
String loadJSON (String url) {
StringBuilder json =
new
StringBuilder();
try
{
URL oracle =
new
URL(url);
URLConnection yc = oracle.openConnection();
BufferedReader in =
new
BufferedReader(
new
InputStreamReader(
yc.getInputStream()));
String inputLine =
null
;
while
( (inputLine = in.readLine()) !=
null
) {
json.append(inputLine);
}
in.close();
}
catch
(MalformedURLException e) {
}
catch
(IOException e) {
}
return
json.toString();
}
}