mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
This commit is contained in:
parent
c998ead188
commit
a3df1d618e
155 changed files with 340 additions and 382 deletions
|
@ -64,7 +64,7 @@ class WinNTFileSystem extends FileSystem {
|
|||
}
|
||||
|
||||
private String slashify(String p) {
|
||||
if ((p.length() > 0) && (p.charAt(0) != slash)) return slash + p;
|
||||
if (!p.isEmpty() && p.charAt(0) != slash) return slash + p;
|
||||
else return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,9 +145,9 @@ public class Handler extends URLStreamHandler {
|
|||
*/
|
||||
String s1 = u1.getHost();
|
||||
String s2 = u2.getHost();
|
||||
if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2)))
|
||||
if ("localhost".equalsIgnoreCase(s1) && (s2 == null || s2.isEmpty()))
|
||||
return true;
|
||||
if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1)))
|
||||
if ("localhost".equalsIgnoreCase(s2) && (s1 == null || s1.isEmpty()))
|
||||
return true;
|
||||
return super.hostsEqual(u1, u2);
|
||||
}
|
||||
|
|
|
@ -141,14 +141,8 @@ class FileDispatcherImpl extends FileDispatcher {
|
|||
|
||||
static boolean isFastFileTransferRequested() {
|
||||
String fileTransferProp = GetPropertyAction
|
||||
.privilegedGetProperty("jdk.nio.enableFastFileTransfer");
|
||||
boolean enable;
|
||||
if ("".equals(fileTransferProp)) {
|
||||
enable = true;
|
||||
} else {
|
||||
enable = Boolean.parseBoolean(fileTransferProp);
|
||||
}
|
||||
return enable;
|
||||
.privilegedGetProperty("jdk.nio.enableFastFileTransfer", "false");
|
||||
return fileTransferProp.isEmpty() ? true : Boolean.parseBoolean(fileTransferProp);
|
||||
}
|
||||
|
||||
static {
|
||||
|
|
|
@ -116,8 +116,7 @@ class WindowsFileAttributes
|
|||
static {
|
||||
String propValue = GetPropertyAction.privilegedGetProperty(
|
||||
"sun.nio.fs.ensureAccurateMetadata", "false");
|
||||
ensureAccurateMetadata = (propValue.length() == 0) ?
|
||||
true : Boolean.valueOf(propValue);
|
||||
ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue);
|
||||
}
|
||||
|
||||
// attributes
|
||||
|
|
|
@ -52,7 +52,7 @@ class WindowsFileStore
|
|||
|
||||
// file store "display name" is the volume name if available
|
||||
String vol = volInfo.volumeName();
|
||||
if (vol.length() > 0) {
|
||||
if (!vol.isEmpty()) {
|
||||
this.displayName = vol;
|
||||
} else {
|
||||
// TBD - should we map all types? Does this need to be localized?
|
||||
|
|
|
@ -218,7 +218,7 @@ class WindowsFileSystem
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(first);
|
||||
for (String segment: more) {
|
||||
if (segment.length() > 0) {
|
||||
if (!segment.isEmpty()) {
|
||||
if (sb.length() > 0)
|
||||
sb.append('\\');
|
||||
sb.append(segment);
|
||||
|
|
|
@ -329,7 +329,7 @@ class WindowsLinkSupport {
|
|||
|
||||
// remove special prefix
|
||||
String target = stripPrefix(new String(name));
|
||||
if (target.length() == 0) {
|
||||
if (target.isEmpty()) {
|
||||
throw new IOException("Symbolic link target is invalid");
|
||||
}
|
||||
return target;
|
||||
|
|
|
@ -243,7 +243,7 @@ class WindowsPath implements Path {
|
|||
// relative to default directory
|
||||
String remaining = path.substring(root.length());
|
||||
String defaultDirectory = getFileSystem().defaultDirectory();
|
||||
if (remaining.length() == 0) {
|
||||
if (remaining.isEmpty()) {
|
||||
return defaultDirectory;
|
||||
} else if (defaultDirectory.endsWith("\\")) {
|
||||
return defaultDirectory + remaining;
|
||||
|
@ -299,7 +299,7 @@ class WindowsPath implements Path {
|
|||
// -- Path operations --
|
||||
|
||||
private boolean isEmpty() {
|
||||
return path.length() == 0;
|
||||
return path.isEmpty();
|
||||
}
|
||||
|
||||
private WindowsPath emptyPath() {
|
||||
|
@ -340,7 +340,7 @@ class WindowsPath implements Path {
|
|||
|
||||
@Override
|
||||
public WindowsPath getRoot() {
|
||||
if (root.length() == 0)
|
||||
if (root.isEmpty())
|
||||
return null;
|
||||
return new WindowsPath(getFileSystem(), type, root, root);
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ class WindowsPath implements Path {
|
|||
|
||||
// corner case - all names removed
|
||||
if (remaining == 0) {
|
||||
return (root.length() == 0) ? emptyPath() : getRoot();
|
||||
return root.isEmpty() ? emptyPath() : getRoot();
|
||||
}
|
||||
|
||||
// re-constitute the path from the remaining names.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue