< prev index next >

src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java

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

@@ -431,11 +431,11 @@
             replyBuf.setLength(0);
             if (logger.isLoggable(PlatformLogger.Level.FINEST)) {
                 logger.finest("Server [" + serverAddr + "] --> " + response);
             }
 
-            if (response.length() == 0) {
+            if (response.isEmpty()) {
                 code = -1;
             } else {
                 try {
                     code = Integer.parseInt(response, 0, 3, 10);
                 } catch (NumberFormatException e) {

@@ -1047,11 +1047,11 @@
      */
     public sun.net.ftp.FtpClient login(String user, char[] password) throws sun.net.ftp.FtpProtocolException, IOException {
         if (!isConnected()) {
             throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
         }
-        if (user == null || user.length() == 0) {
+        if (user == null || user.isEmpty()) {
             throw new IllegalArgumentException("User name can't be null or empty");
         }
         tryLogin(user, password);
 
         // keep the welcome message around so we can

@@ -1086,11 +1086,11 @@
     public sun.net.ftp.FtpClient login(String user, char[] password, String account) throws sun.net.ftp.FtpProtocolException, IOException {
 
         if (!isConnected()) {
             throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
         }
-        if (user == null || user.length() == 0) {
+        if (user == null || user.isEmpty()) {
             throw new IllegalArgumentException("User name can't be null or empty");
         }
         tryLogin(user, password);
 
         /*

@@ -1150,11 +1150,11 @@
      * @param remoteDirectory path of the directory to CD to.
      * @return <code>true</code> if the operation was successful.
      * @exception <code>FtpProtocolException</code>
      */
     public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
-        if (remoteDirectory == null || "".equals(remoteDirectory)) {
+        if (remoteDirectory == null || remoteDirectory.isEmpty()) {
             throw new IllegalArgumentException("directory can't be null or empty");
         }
 
         issueCommandCheck("CWD " + remoteDirectory);
         return this;

@@ -1736,11 +1736,11 @@
      *         the server returned an error, which can be checked with
      *         {@link #getLastReplyCode()}.
      * @throws IOException if an error occurs during the transmission.
      */
     public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
-        if (path == null || path.length() == 0) {
+        if (path == null || path.isEmpty()) {
             throw new IllegalArgumentException("path can't be null or empty");
         }
         issueCommandCheck("SIZE " + path);
         if (lastReplyCode == FtpReplyCode.FILE_STATUS) {
             String s = getResponseString();
< prev index next >