Java String Capitalize capitalize(String s, char delimiter)

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

Description

capitalize

License

Open Source License

Parameter

Parameter Description
s the string which should be capitalized.
delimiter the character after which the next letter should be capitalized.

Return

a capitalized version of the string provided.

Declaration

public static String capitalize(String s, char delimiter) 

Method Source Code

//package com.java2s;
/*//from  w  ww .  j  a va 2 s . c o  m
 * Copyright (C) Keanu Poeschko - All Rights Reserved
 * Unauthorized copying of this file is strictly prohibited
 *
 * Created by Keanu Poeschko <nur1popcorn@gmail.com>, April 2017
 * This file is part of {Irrlicht}.
 *
 * Do not copy or distribute files of {Irrlicht} without permission of {Keanu Poeschko}
 *
 * Permission to use, copy, modify, and distribute my software for
 * educational, and research purposes, without a signed licensing agreement
 * and for free, is hereby granted, provided that the above copyright notice
 * and this paragraph appear in all copies, modifications, and distributions.
 *
 *
 *
 *
 */

public class Main {
    /**
     * @param s the string which should be capitalized.
     * @param delimiter the character after which the next letter should be capitalized.
     *
     * @return a capitalized version of the string provided.
     */
    public static String capitalize(String s, char delimiter) {
        boolean capitalize = true;
        final char chars[] = s.toCharArray();
        for (int i = 0; i < s.length(); i++) {
            chars[i] = capitalize ? Character.toUpperCase(chars[i]) : Character.toLowerCase(chars[i]);
            capitalize = chars[i] == delimiter;
        }
        return new String(chars);
    }
}

Related

  1. capitalize(String s)
  2. capitalize(String s)
  3. capitalize(String s)
  4. capitalize(String s)
  5. capitalize(String s)
  6. capitalize(String s, String fullstring)
  7. capitalize(String source)
  8. capitalize(String src)
  9. capitalize(String str)