Java String Line Count countLines(String str)

Here you can find the source of countLines(String str)

Description

count Lines

License

Apache License

Declaration

static int countLines(String str) 

Method Source Code

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

public class Main {
    static int countLines(String str) {
        if (str == null || str.isEmpty())
            return 0;

        int lines = 1;
        int pos = 0;
        while ((pos = str.indexOf("\n", pos) + 1) != 0)
            lines++;/*from  ww w . j av  a  2s  .  c  o m*/

        return lines;
    }
}

Related

  1. countLines(String data)
  2. countLines(String input)
  3. countLines(String o)
  4. countLines(String s)
  5. countLines(String s)
  6. countLines(String text)
  7. countLines(String text)
  8. countLines(String value)
  9. countLines(String what)