Java String Line Count countLines(String data)

Here you can find the source of countLines(String data)

Description

Counts the number of lines in this String.

License

Open Source License

Declaration

public static Integer countLines(String data) 

Method Source Code

//package com.java2s;
/*/* w  ww .  ja v  a2  s .co m*/
 * Copyright (c) Mirth Corporation. All rights reserved.
 * 
 * http://www.mirthcorp.com
 * 
 * The software in this package is published under the terms of the MPL license a copy of which has
 * been included with this distribution in the LICENSE.txt file.
 */

public class Main {
    /**
     * Counts the number of lines in this String.
     */
    public static Integer countLines(String data) {
        if (data == null) {
            return null;
        }
        return data.split("\r\n|\r|\n").length;
    }
}

Related

  1. countLineBreaks(String text)
  2. countLineEnds(CharSequence string, int startPos)
  3. countLines(final String content, final String lineBreak)
  4. countLines(String aMessage)
  5. countLines(String buffer)
  6. countLines(String input)
  7. countLines(String o)
  8. countLines(String s)
  9. countLines(String s)