Java Char Create toChars(String s)

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

Description

Converts a String to char[].

License

Open Source License

Declaration

public static char[] toChars(String s) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright ? 2000, 2013 IBM Corporation and others.
 * 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
 *
 * Contributors:/*from  w  ww  . j  ava 2s .co m*/
 * IBM Corporation - initial API and implementation
 *
 *******************************************************************************/

public class Main {
    /**
     * Converts a String to char[].
     */
    public static char[] toChars(String s) {
        int len = s.length();
        char[] chars = new char[len];
        s.getChars(0, len, chars, 0);
        return chars;
    }
}

Related

  1. toChars(final int cp, final char[] buffer, final int offset)
  2. toChars(int codePoint, char[] dst, int dstIndex)
  3. toChars(int number, char chars[])
  4. toChars(int[] src, int srcOff, int srcLen, char[] dest, int destOff)
  5. toChars(String from)
  6. toCharSequence(final Object value)
  7. toCharString(byte[] bytes)
  8. toCharWithoutOverflow(double value)