Java Char Array Create toCharArray(String str)

Here you can find the source of toCharArray(String str)

Description

Safe-get for null Strings to char array conversion.

License

Open Source License

Parameter

Parameter Description
str a parameter

Return

String as char array. If the input is null output will be null

Declaration

public static final char[] toCharArray(String str) 

Method Source Code

//package com.java2s;
/*//w  w w. j a  v  a 2s .  c o  m
 * Copyright 2004 - 2008 Christian Sprajc. All rights reserved.
 *
 * This file is part of PowerFolder.
 *
 * PowerFolder is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * PowerFolder is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PowerFolder. If not, see <http://www.gnu.org/licenses/>.
 *
 * $Id: Util.java 20555 2012-12-25 04:15:08Z glasgow $
 */

public class Main {
    /**
     * Safe-get for null Strings to char array conversion.
     * 
     * @param str
     * @return String as char array. If the input is null output will be null
     */
    public static final char[] toCharArray(String str) {
        if (str == null) {
            return null;
        }
        return str.toCharArray();
    }
}

Related

  1. toCharArray(String map)
  2. toCharArray(String s)
  3. toCharArray(String s)
  4. toCharArray(String s)
  5. toCharArray(String str)
  6. toCharArray(String str)
  7. toCharArray(String string)
  8. toCharArray(String[] v)
  9. toCharArray(StringBuffer stringbuffer)