Ec2Snitch.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:ACaZoo 作者:
String awsApiCall(String url) throws IOException, ConfigurationException
{
    // Populate the region and zone by introspection, fail if 404 on metadata
    HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
    DataInputStream d = null;
    try
    {
        conn.setRequestMethod("GET");
        if (conn.getResponseCode() != 200)
            throw new ConfigurationException("Ec2Snitch was unable to execute the API call. Not an ec2 node?");

        // Read the information. I wish I could say (String) conn.getContent() here...
        int cl = conn.getContentLength();
        byte[] b = new byte[cl];
        d = new DataInputStream((FilterInputStream) conn.getContent());
        d.readFully(b);
        return new String(b, Charsets.UTF_8);
    }
    finally
    {
        FileUtils.close(d);
        conn.disconnect();
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号