public class Newlines extends Object
| Constructor and Description |
|---|
Newlines() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
containsBreaks(String text)
Returns true if the input contains any line breaks.
|
static int |
count(String input)
Returns the number of line breaks in the input.
|
static int |
firstBreak(String input)
Returns the index of the first break in the input, or
-1. |
static String |
getLineEnding(String input)
Returns the terminating line break in the input, or
null if the input does not end in a
break. |
static String |
guessLineSeparator(String text)
Returns the first line separator in the text, or
"\n" if the text does not contain a
single line separator. |
static int |
hasNewlineAt(String input,
int idx)
Returns the length of the newline sequence at the current offset, or
-1. |
static boolean |
isNewline(String input)
Returns true if the entire input string is a recognized line break.
|
static Iterator<String> |
lineIterator(String input)
Returns an iterator over lines in the input, including trailing whitespace.
|
static Iterator<Integer> |
lineOffsetIterator(String input)
Returns an iterator over the start offsets of lines in the input.
|
public static int count(String input)
public static int firstBreak(String input)
-1.public static boolean isNewline(String input)
public static int hasNewlineAt(String input, int idx)
-1.public static String getLineEnding(String input)
null if the input does not end in a
break.public static String guessLineSeparator(String text)
"\n" if the text does not contain a
single line separator.public static boolean containsBreaks(String text)
public static Iterator<Integer> lineOffsetIterator(String input)
Copyright © 2015–2017 Google Inc.. All rights reserved.