Java tutorial
//package com.java2s; /** * This file is part of the Open Web Application Security Project (OWASP) Java File IO Security project. For details, please see * <a href="https://www.owasp.org/index.php/OWASP_Java_File_I_O_Security_Project">https://www.owasp.org/index.php/OWASP_Java_File_I_O_Security_Project</a>. * * Copyright (c) 2014 - The OWASP Foundation * * This API is published by OWASP under the Apache 2.0 license. You should read and accept the LICENSE before you use, modify, and/or redistribute this software. * * @author Neil Matatall (neil.matatall .at. gmail.com) - Original ESAPI author * @author August Detlefsen <a href="http://www.codemagi.com">CodeMagi</a> - Java File IO Security Project lead * @created 2014 */ public class Main { private static final char[] EMPTY_CHAR_ARRAY = new char[0]; /** * Convert a String to a char array * * @param str The string to convert * @return character array containing the characters in str. An empty array is returned if str is null. */ public static char[] strToChars(String str) { int len; char[] ret; if (str == null) { return EMPTY_CHAR_ARRAY; } len = str.length(); ret = new char[len]; str.getChars(0, len, ret, 0); return ret; } }