Java String Clean cleanString(String aString)

Here you can find the source of cleanString(String aString)

Description

Cleans a string, removing all ' ' and '\t'

License

Open Source License

Parameter

Parameter Description
aString to be cleaned

Return

a cleaned string

Declaration


public static String cleanString(String aString) 

Method Source Code

//package com.java2s;
/*//from  www  .j  a v  a2 s  .c  om
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description: 
*
*/

public class Main {
    /**
     * 
     * Cleans a string, removing all ' ' and '\t'
     * 
     * @param aString
     *            to be cleaned
     * @return a cleaned string
     */

    public static String cleanString(String aString) {
        StringBuffer lStringBuffer = new StringBuffer();
        for (int lStringIndex = 0; lStringIndex < aString.length(); lStringIndex++) {
            if (aString.charAt(lStringIndex) != ' ' && aString.charAt(lStringIndex) != '\t') {
                lStringBuffer.append(aString.charAt(lStringIndex));
            }
        }
        return lStringBuffer.toString();
    }
}

Related

  1. cleanString(String field)
  2. cleanString(String input, char ol, char ne)
  3. cleanString(String statement)
  4. cleanString(String unallowableCharacters, String stringToClean)