JAvaアナログ呼び出しサーブレット
1000 ワード
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 + "
";
}
System.out.print(strResponse);
}