Java String Whitespace Delete deleteWhiteSpace(String s)

Here you can find the source of deleteWhiteSpace(String s)

Description

delete White Space

License

Open Source License

Declaration

public static String deleteWhiteSpace(String s) 

Method Source Code

//package com.java2s;
/**/*  www  .  j  a va 2 s  .c  o m*/
 *  Copyright (c)  2016-2020 Weibo, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Weibo, 
 *  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 Weibo.
 */

public class Main {

    public static String deleteWhiteSpace(String s) {
        StringBuilder r = new StringBuilder();
        if (s != null) {
            for (int i = 0; i < s.length(); i++) {
                if (!Character.isWhitespace(s.codePointAt(i))) {
                    r.append(s.charAt(i));
                }
            }
        }
        return r.toString();
    }
}

Related

  1. deleteWhitespace(CharSequence sequence)
  2. deleteWhitespace(CharSequence str)
  3. deleteWhitespace(final String s)
  4. deleteWhitespace(final String str)
  5. deleteWhitespace(String s)
  6. deleteWhitespace(String str)
  7. deleteWhitespace(String str)
  8. deleteWhitespace(String str)
  9. deleteWhitespace(String str)