src/java.base/share/classes/java/lang/String.java
changeset 50215 2fb27c352cae
parent 50175 589ed2770141
child 50237 ec52b4d094c0
equal deleted inserted replaced
50214:9bdd233f270d 50215:2fb27c352cae
    39 import java.util.StringJoiner;
    39 import java.util.StringJoiner;
    40 import java.util.regex.Matcher;
    40 import java.util.regex.Matcher;
    41 import java.util.regex.Pattern;
    41 import java.util.regex.Pattern;
    42 import java.util.regex.PatternSyntaxException;
    42 import java.util.regex.PatternSyntaxException;
    43 import java.util.stream.IntStream;
    43 import java.util.stream.IntStream;
       
    44 import java.util.stream.Stream;
    44 import java.util.stream.StreamSupport;
    45 import java.util.stream.StreamSupport;
    45 import jdk.internal.HotSpotIntrinsicCandidate;
    46 import jdk.internal.HotSpotIntrinsicCandidate;
    46 import jdk.internal.vm.annotation.Stable;
    47 import jdk.internal.vm.annotation.Stable;
    47 
    48 
    48 /**
    49 /**
  2752             return StringUTF16.indexOfNonWhitespace(value);
  2753             return StringUTF16.indexOfNonWhitespace(value);
  2753         }
  2754         }
  2754     }
  2755     }
  2755 
  2756 
  2756     /**
  2757     /**
       
  2758      * Returns a stream of substrings extracted from this string
       
  2759      * partitioned by line terminators.
       
  2760      * <p>
       
  2761      * Line terminators recognized are line feed
       
  2762      * {@code "\n"} ({@code U+000A}),
       
  2763      * carriage return
       
  2764      * {@code "\r"} ({@code U+000D})
       
  2765      * and a carriage return followed immediately by a line feed
       
  2766      * {@code "\r\n"} ({@code U+000D U+000A}).
       
  2767      * <p>
       
  2768      * The stream returned by this method contains each line of
       
  2769      * this string that is terminated by a line terminator except that
       
  2770      * the last line can either be terminated by a line terminator or the
       
  2771      * end of the string.
       
  2772      * The lines in the stream are in the order in which
       
  2773      * they occur in this string and do not include the line terminators
       
  2774      * partitioning the lines.
       
  2775      *
       
  2776      * @implNote This method provides better performance than
       
  2777      *           split("\R") by supplying elements lazily and
       
  2778      *           by faster search of new line terminators.
       
  2779      *
       
  2780      * @return  the stream of strings extracted from this string
       
  2781      *          partitioned by line terminators
       
  2782      *
       
  2783      * @since 11
       
  2784      */
       
  2785     public Stream<String> lines() {
       
  2786         return isLatin1() ? StringLatin1.lines(value)
       
  2787                           : StringUTF16.lines(value);
       
  2788     }
       
  2789 
       
  2790     /**
  2757      * This object (which is already a string!) is itself returned.
  2791      * This object (which is already a string!) is itself returned.
  2758      *
  2792      *
  2759      * @return  the string itself.
  2793      * @return  the string itself.
  2760      */
  2794      */
  2761     public String toString() {
  2795     public String toString() {