Java String Underscore to underscoreToSpace(String value)

Here you can find the source of underscoreToSpace(String value)

Description

underscore To Space

License

Apache License

Declaration

public static String underscoreToSpace(String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static String underscoreToSpace(String value) {
        if (value == null) {
            throw new IllegalArgumentException("Passed value can not be null.");
        }/*from   w ww . j  av  a 2  s  .  com*/
        return underscoresToSpaces(value, false);
    }

    public static String underscoresToSpaces(String value) {
        if (value == null) {
            throw new IllegalArgumentException("Passed value can not be null.");
        }
        return underscoresToSpaces(value, true);
    }

    private static String underscoresToSpaces(String value, boolean all) {
        if (value == null) {
            throw new IllegalArgumentException("Passed value can not be null.");
        }
        if (all) {
            return value.replace("_", " ");
        } else {
            return value.replaceFirst("_", " ");
        }
    }
}

Related

  1. underscoresToSpaces(String value)
  2. underscoreToCamel(String input, boolean firstLetterUppercase)
  3. underscoreToCamelCase(String wordConstruct)
  4. underscoreToPascalCase(final String str)
  5. underscoreToSpace(String text)