Here you can find the source of toChars(String s)
public static char[] toChars(String s)
//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; } }