Java String Camel Case camelCase(String s)

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

Description

camel Case

License

Open Source License

Declaration

public static byte[] camelCase(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 MATERNA Information & Communications. All rights reserved.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html. For further
 * project-related information visit http://www.ws4d.org. The most recent
 * version of the JMEDS framework can be obtained from
 * http://sourceforge.net/projects/ws4d-javame.
 ******************************************************************************/

public class Main {
    public static byte[] camelCase(String s) {
        byte[] b = s.getBytes();
        boolean camel = true;
        for (int i = 0; i < b.length; i++) {
            if (b[i] >= 97 && b[i] <= 122 && camel) {
                b[i] = (byte) (b[i] - 32);
                camel = false;//w  w  w  .ja v a 2s .  c  o m
            }
            if (b[i] == 32 && !camel) {
                camel = true;
            }
            if (b[i] == 45 && !camel) {
                camel = true;
            }
        }
        return b;
    }
}

Related

  1. camelCase(String key)
  2. camelCase(String name, boolean capitalize)
  3. camelCase(String s)
  4. camelCase(String s)
  5. camelCase(String s)
  6. camelCase(String s)
  7. camelCase(String str)
  8. CamelCase(String str)
  9. camelCase(String string, boolean firstUpper)