Java String Remove removeSomeOne(String words, int count)

Here you can find the source of removeSomeOne(String words, int count)

Description

remove Some One

License

Open Source License

Declaration

public static String removeSomeOne(String words, int count) 

Method Source Code


//package com.java2s;
/*/* w  w  w.  j  a  va  2s  . co  m*/
 *
 *  *****************************************************************************
 *  * Copyright ( c ) 2016 Heren Tianjin Inc. All Rights Reserved.
 *  *
 *  * This software is the confidential and proprietary information of Heren Tianjin Inc
 *  * ("Confidential Information").  You shall not disclose such Confidential Information
 *  *  and shall use it only in accordance with the terms of the license agreement
 *  *  you entered into with Heren Tianjin or a Heren Tianjin authorized
 *  *  reseller (the "License Agreement").
 *  ****************************************************************************
 *
 */

import java.util.Arrays;

public class Main {
    public static String removeSomeOne(String words, int count) {
        String[] word = words.split("\\^");
        int wordsLength = word.length;
        if (count < wordsLength) {
            System.arraycopy(word, count + 1, word, count, wordsLength - 1 - count);
            String[] newWords = Arrays.copyOf(word, wordsLength - 1);
            StringBuilder sb = new StringBuilder();
            for (String newWord : newWords) {
                sb.append(newWord).append("^");
            }
            return sb.toString().substring(0, sb.length() - 1);
        } else {
            return words;
        }
    }
}

Related

  1. removeProperty(String name)
  2. removePropertyNameModifier(String name)
  3. removePunctuation(String str)
  4. removePunctuation(String value)
  5. removeRecursive(Object json, String keyToRemove)
  6. removeSpaces(String orig)
  7. removeSpecialChars(final String word)
  8. removeSpecialCharsForSQLRegExp(String _s)
  9. removeUnusedData(String songData)