Java String Line Count countLines(StringBuffer bigBuffer)

Here you can find the source of countLines(StringBuffer bigBuffer)

Description

count Lines

License

Open Source License

Declaration

public static int countLines(StringBuffer bigBuffer) 

Method Source Code

//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());
    }
}

Related

  1. countLines(String str)
  2. countLines(String text)
  3. countLines(String text)
  4. countLines(String value)
  5. countLines(String what)
  6. countLineTypes(String line)