Here you can find the source of countLines(String aMessage)
public static int countLines(String aMessage)
//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; } }