Here you can find the source of countLineBreaks(String text)
public static int countLineBreaks(String text)
//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; } }