src/java.base/share/classes/java/lang/String.java
changeset 50175 589ed2770141
parent 50098 92560438d306
child 50215 2fb27c352cae
equal deleted inserted replaced
50174:78d9ffb8146f 50175:589ed2770141
  2727                                 : StringUTF16.stripTrailing(value);
  2727                                 : StringUTF16.stripTrailing(value);
  2728         return ret == null ? this : ret;
  2728         return ret == null ? this : ret;
  2729     }
  2729     }
  2730 
  2730 
  2731     /**
  2731     /**
       
  2732      * Returns {@code true} if the string is empty or contains only
       
  2733      * {@link Character#isWhitespace(int) white space} codepoints,
       
  2734      * otherwise {@code false}.
       
  2735      *
       
  2736      * @return {@code true} if the string is empty or contains only
       
  2737      *         {@link Character#isWhitespace(int) white space} codepoints,
       
  2738      *         otherwise {@code false}
       
  2739      *
       
  2740      * @see Character#isWhitespace(int)
       
  2741      *
       
  2742      * @since 11
       
  2743      */
       
  2744     public boolean isBlank() {
       
  2745         return indexOfNonWhitespace() == length();
       
  2746     }
       
  2747 
       
  2748     private int indexOfNonWhitespace() {
       
  2749         if (isLatin1()) {
       
  2750             return StringLatin1.indexOfNonWhitespace(value);
       
  2751         } else {
       
  2752             return StringUTF16.indexOfNonWhitespace(value);
       
  2753         }
       
  2754     }
       
  2755 
       
  2756     /**
  2732      * This object (which is already a string!) is itself returned.
  2757      * This object (which is already a string!) is itself returned.
  2733      *
  2758      *
  2734      * @return  the string itself.
  2759      * @return  the string itself.
  2735      */
  2760      */
  2736     public String toString() {
  2761     public String toString() {