Java String Capitalize capitalize(String str, String delimiter)

Here you can find the source of capitalize(String str, String delimiter)

Description

capitalize

License

Open Source License

Declaration

public static String capitalize(String str, String delimiter) 

Method Source Code

//package com.java2s;
/*//from   w  w  w. j ava  2  s . c  o  m
 * Scriptographer
 *
 * This file is part of Scriptographer, a Scripting Plugin for Adobe Illustrator
 * http://scriptographer.org/
 *
 * Copyright (c) 2002-2010, Juerg Lehni
 * http://scratchdisk.com/
 *
 * All rights reserved. See LICENSE file for details.
 * 
 * File created on 08.12.2006.
 */

public class Main {
    public static String capitalize(String str, String delimiter) {
        String[] parts = str.split("\\s");
        StringBuffer res = new StringBuffer();
        for (int i = 0, l = parts.length; i < l; i++) {
            if (i > 0)
                res.append(delimiter);
            String part = parts[i];
            res.append(Character.toUpperCase(part.charAt(0)));
            res.append(part, 1, part.length());
        }
        return res.toString();
    }

    public static String capitalize(String str) {
        return capitalize(str, "");
    }
}

Related

  1. capitalize(String str)
  2. capitalize(String str)
  3. capitalize(String str, char... delimiters)
  4. capitalize(String str, char[] wordDelimiters)
  5. capitalize(String str, String delim)
  6. capitalize(String string)
  7. capitalize(String string)
  8. capitalize(String string)
  9. capitalize(String string)