public static void main(String[] args) throws Exception {
Properties property = new Properties();
BufferedInputStream inBuff = null;
inBuff = new BufferedInputStream(new PostRequestEmulator().getClass().getResourceAsStream("/attach.properties"));
property.load(inBuff);
// 服务地址
URL url = new URL(property.getProperty("key"));
// 设定连接的相关参数
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
// 获取服务端的反馈
String strLine = "";
String strResponse = "";
InputStream in = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
while ((strLine = reader.readLine()) != null){
strResponse += strLine + "\n";
}
System.out.print(strResponse);
}