< prev index next >

src/java.base/share/classes/java/net/NetworkInterface.java

Print this page




 153             try {
 154                 if (!trusted) {
 155                     sec.checkConnect(addrs[j].getHostAddress(), -1);
 156                 }
 157                 local_addrs[i++] = addrs[j];
 158             } catch (SecurityException e) { }
 159         }
 160         return Arrays.copyOf(local_addrs, i);
 161     }
 162 
 163     /**
 164      * Get a List of all or a subset of the {@code InterfaceAddresses}
 165      * of this network interface.
 166      * <p>
 167      * If there is a security manager, its {@code checkConnect}
 168      * method is called with the InetAddress for each InterfaceAddress.
 169      * Only InterfaceAddresses where the {@code checkConnect} doesn't throw
 170      * a SecurityException will be returned in the List.
 171      *
 172      * @return a {@code List} object with all or a subset of the
 173      *         InterfaceAddresss of this network interface
 174      * @since 1.6
 175      */
 176     public java.util.List<InterfaceAddress> getInterfaceAddresses() {
 177         java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1);
 178         if (bindings != null) {
 179             SecurityManager sec = System.getSecurityManager();
 180             for (int j=0; j<bindings.length; j++) {
 181                 try {
 182                     if (sec != null) {
 183                         sec.checkConnect(bindings[j].getAddress().getHostAddress(), -1);
 184                     }
 185                     lst.add(bindings[j]);
 186                 } catch (SecurityException e) { }
 187             }
 188         }
 189         return lst;
 190     }
 191 
 192     /**
 193      * Get an Enumeration with all the subinterfaces (also known as virtual




 153             try {
 154                 if (!trusted) {
 155                     sec.checkConnect(addrs[j].getHostAddress(), -1);
 156                 }
 157                 local_addrs[i++] = addrs[j];
 158             } catch (SecurityException e) { }
 159         }
 160         return Arrays.copyOf(local_addrs, i);
 161     }
 162 
 163     /**
 164      * Get a List of all or a subset of the {@code InterfaceAddresses}
 165      * of this network interface.
 166      * <p>
 167      * If there is a security manager, its {@code checkConnect}
 168      * method is called with the InetAddress for each InterfaceAddress.
 169      * Only InterfaceAddresses where the {@code checkConnect} doesn't throw
 170      * a SecurityException will be returned in the List.
 171      *
 172      * @return a {@code List} object with all or a subset of the
 173      *         InterfaceAddress of this network interface
 174      * @since 1.6
 175      */
 176     public java.util.List<InterfaceAddress> getInterfaceAddresses() {
 177         java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1);
 178         if (bindings != null) {
 179             SecurityManager sec = System.getSecurityManager();
 180             for (int j=0; j<bindings.length; j++) {
 181                 try {
 182                     if (sec != null) {
 183                         sec.checkConnect(bindings[j].getAddress().getHostAddress(), -1);
 184                     }
 185                     lst.add(bindings[j]);
 186                 } catch (SecurityException e) { }
 187             }
 188         }
 189         return lst;
 190     }
 191 
 192     /**
 193      * Get an Enumeration with all the subinterfaces (also known as virtual


< prev index next >