Here you can find the source of countLines(StringBuffer bigBuffer)
public static int countLines(StringBuffer bigBuffer)
//package com.java2s; /*//from w ww. ja va 2s . c om * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. */ public class Main { public static int countLines(String bigString) { int count = 1; int len_m1 = bigString.length() - 1; for (int i = 1; i < len_m1; i++) { if (bigString.charAt(i) == '\n') { count++; } } return count; } public static int countLines(StringBuffer bigBuffer) { return countLines(bigBuffer.toString()); } }