Java String Line Count countLineBreaks(String text)

Here you can find the source of countLineBreaks(String text)

Description

count Line Breaks

License

Apache License

Declaration

public static int countLineBreaks(String text) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int countLineBreaks(String text) {
        char[] chars = text.toCharArray();
        int count = 0;
        for (int index = 0; index < text.length(); index++) {
            if (chars[index] == '\n') {
                count++;/*from  w ww  .  j av a 2 s  .  c o  m*/
            }
        }
        return count;
    }
}

Related

  1. countLine(CharSequence str)
  2. countLine(String content)
  3. countLine(String contents, int index)
  4. countLineBreaks(final String replacementString)
  5. countLineEnds(CharSequence string, int startPos)
  6. countLines(final String content, final String lineBreak)
  7. countLines(String aMessage)
  8. countLines(String buffer)