< prev index next >

src/java.base/share/classes/java/io/File.java

Print this page
rev 52881 : 8214971: Replace use of string.equals("") with isEmpty()
Reviewed-by: jlaskey, prappo, lancea, dfuchs, redestad

*** 255,265 **** * The parameter order is used to disambiguate this method from the * public(File, String) constructor. */ private File(String child, File parent) { assert parent.path != null; ! assert (!parent.path.equals("")); this.path = fs.resolve(parent.path, child); this.prefixLength = parent.prefixLength; } /** --- 255,265 ---- * The parameter order is used to disambiguate this method from the * public(File, String) constructor. */ private File(String child, File parent) { assert parent.path != null; ! assert (!parent.path.isEmpty()); this.path = fs.resolve(parent.path, child); this.prefixLength = parent.prefixLength; } /**
*** 314,324 **** public File(String parent, String child) { if (child == null) { throw new NullPointerException(); } if (parent != null) { ! if (parent.equals("")) { this.path = fs.resolve(fs.getDefaultParent(), fs.normalize(child)); } else { this.path = fs.resolve(fs.normalize(parent), fs.normalize(child)); --- 314,324 ---- public File(String parent, String child) { if (child == null) { throw new NullPointerException(); } if (parent != null) { ! if (parent.isEmpty()) { this.path = fs.resolve(fs.getDefaultParent(), fs.normalize(child)); } else { this.path = fs.resolve(fs.normalize(parent), fs.normalize(child));
*** 357,367 **** public File(File parent, String child) { if (child == null) { throw new NullPointerException(); } if (parent != null) { ! if (parent.path.equals("")) { this.path = fs.resolve(fs.getDefaultParent(), fs.normalize(child)); } else { this.path = fs.resolve(parent.path, fs.normalize(child)); --- 357,367 ---- public File(File parent, String child) { if (child == null) { throw new NullPointerException(); } if (parent != null) { ! if (parent.path.isEmpty()) { this.path = fs.resolve(fs.getDefaultParent(), fs.normalize(child)); } else { this.path = fs.resolve(parent.path, fs.normalize(child));
*** 424,434 **** if (uri.getRawFragment() != null) throw new IllegalArgumentException("URI has a fragment component"); if (uri.getRawQuery() != null) throw new IllegalArgumentException("URI has a query component"); String p = uri.getPath(); ! if (p.equals("")) throw new IllegalArgumentException("URI path component is empty"); // Okay, now initialize p = fs.fromURIPath(p); if (File.separatorChar != '/') --- 424,434 ---- if (uri.getRawFragment() != null) throw new IllegalArgumentException("URI has a fragment component"); if (uri.getRawQuery() != null) throw new IllegalArgumentException("URI has a query component"); String p = uri.getPath(); ! if (p.isEmpty()) throw new IllegalArgumentException("URI path component is empty"); // Okay, now initialize p = fs.fromURIPath(p); if (File.separatorChar != '/')
< prev index next >