< prev index next >
src/java.base/share/classes/java/net/InetAddress.java
Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
@@ -1185,11 +1185,11 @@
* @exception UnknownHostException if IP address is of illegal length
* @since 1.4
*/
public static InetAddress getByAddress(String host, byte[] addr)
throws UnknownHostException {
- if (host != null && host.length() > 0 && host.charAt(0) == '[') {
+ if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1);
}
}
if (addr != null) {
@@ -1299,11 +1299,11 @@
}
private static InetAddress[] getAllByName(String host, InetAddress reqAddr)
throws UnknownHostException {
- if (host == null || host.length() == 0) {
+ if (host == null || host.isEmpty()) {
InetAddress[] ret = new InetAddress[1];
ret[0] = impl.loopbackAddress();
return ret;
}
< prev index next >