< prev index next >

src/java.base/windows/classes/sun/nio/fs/WindowsPath.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD

*** 241,251 **** // Drive relative path ("C:foo" for example). if (isSameDrive(root, getFileSystem().defaultRoot())) { // relative to default directory String remaining = path.substring(root.length()); String defaultDirectory = getFileSystem().defaultDirectory(); ! if (remaining.length() == 0) { return defaultDirectory; } else if (defaultDirectory.endsWith("\\")) { return defaultDirectory + remaining; } else { return defaultDirectory + "\\" + remaining; --- 241,251 ---- // Drive relative path ("C:foo" for example). if (isSameDrive(root, getFileSystem().defaultRoot())) { // relative to default directory String remaining = path.substring(root.length()); String defaultDirectory = getFileSystem().defaultDirectory(); ! if (remaining.isEmpty()) { return defaultDirectory; } else if (defaultDirectory.endsWith("\\")) { return defaultDirectory + remaining; } else { return defaultDirectory + "\\" + remaining;
*** 297,307 **** } // -- Path operations -- private boolean isEmpty() { ! return path.length() == 0; } private WindowsPath emptyPath() { return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", ""); } --- 297,307 ---- } // -- Path operations -- private boolean isEmpty() { ! return path.isEmpty(); } private WindowsPath emptyPath() { return new WindowsPath(getFileSystem(), WindowsPathType.RELATIVE, "", ""); }
*** 338,348 **** path.substring(0, off)); } @Override public WindowsPath getRoot() { ! if (root.length() == 0) return null; return new WindowsPath(getFileSystem(), type, root, root); } // package-private --- 338,348 ---- path.substring(0, off)); } @Override public WindowsPath getRoot() { ! if (root.isEmpty()) return null; return new WindowsPath(getFileSystem(), type, root, root); } // package-private
*** 554,564 **** if (remaining == count) return this; // corner case - all names removed if (remaining == 0) { ! return (root.length() == 0) ? emptyPath() : getRoot(); } // re-constitute the path from the remaining names. StringBuilder result = new StringBuilder(); if (root != null) --- 554,564 ---- if (remaining == count) return this; // corner case - all names removed if (remaining == 0) { ! return root.isEmpty() ? emptyPath() : getRoot(); } // re-constitute the path from the remaining names. StringBuilder result = new StringBuilder(); if (root != null)
< prev index next >