KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > util > Strings


1 /*******************************************************************************
2  * Copyright (c) 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ltk.internal.ui.refactoring.util;
12
13 /**
14  * Utility class for string-related functions.
15  */

16 public final class Strings {
17
18     public static String JavaDoc removeNewLine(String JavaDoc message) {
19         final StringBuffer JavaDoc result= new StringBuffer JavaDoc();
20         int current= 0;
21         int index= message.indexOf('\n', 0);
22         while (index != -1) {
23             result.append(message.substring(current, index));
24             if (current < index && index != 0)
25                 result.append(' ');
26             current= index + 1;
27             index= message.indexOf('\n', current);
28         }
29         result.append(message.substring(current));
30         return result.toString();
31     }
32
33     private Strings() {
34         // Not for instantiation
35
}
36 }
Popular Tags