Here you can find the source of countLine(String content)
public static int countLine(String content)
//package com.java2s; //License from project: Apache License public class Main { public static int countLine(String content) { return countHappens('\n', content) + 1; }//from www . j a v a2 s . co m /** * * @param chr * @param string * @return count */ public static int countHappens(char chr, CharSequence string) { if (string == null) { return 0; } int length = string.length(); int count = 0; for (int i = 0; i < length; i++) { if (string.charAt(i) == chr) count++; } return count; } }