Java String Line Count countLines(String aMessage)

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

Description

count Lines

License

Open Source License

Declaration

public static int countLines(String aMessage) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011-2012 Nokia Corporation
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// www  .j av a 2 s. c  o  m
 * Comarch team - initial API and implementation
 *******************************************************************************/

public class Main {
    public static int countLines(String aMessage) {
        int lastPos = 0;
        int count = 1;
        while (-1 != (lastPos = aMessage.indexOf("\n", lastPos + 1))) {
            ++count;
        }
        return count;
    }
}

Related

  1. countLine(String contents, int index)
  2. countLineBreaks(final String replacementString)
  3. countLineBreaks(String text)
  4. countLineEnds(CharSequence string, int startPos)
  5. countLines(final String content, final String lineBreak)
  6. countLines(String buffer)
  7. countLines(String data)
  8. countLines(String input)
  9. countLines(String o)