虚假资源泄漏警告?

时间:2012-12-20 08:42:59

标签: java eclipse compiler-warnings java-7 try-with-resources

我在“'和' p'在这个片段中。这个警告有效吗?

try (StringWriter s = new StringWriter(); PrintWriter p = new PrintWriter(s)) {
    p.print(InetAddress.getLocalHost().getHostName());
    p.print('/');
    Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
    while (e.hasMoreElements()) {
        NetworkInterface i = e.nextElement();
        System.out.println(i);
        if (i.getHardwareAddress() == null || i.getHardwareAddress().length == 0)
            continue;
        for (byte b : i.getHardwareAddress())
            p.printf("%02x", b);
        return s.toString();
    }
    throw new RuntimeException("Unable to determine Host ID");
}

1 个答案:

答案 0 :(得分:0)

在这个片段中 - 没有。除了由JVM管理的资源之外,没有资源可以谈论。