Java Utililty Methods String to Array

List of utility methods to do String to Array

Description

The list of methods to do String to Array are organized into topic(s).

Method

String[]stringToArray(final String data, final String delim)
transforms a string list into an array of Strings.
if (data == null) {
    return new String[0];
final List tokens = new ArrayList(data.length() / 10);
int pointer = 0;
int quotePointer = 0;
int tokenStart = 0;
int nextDelimiter;
...
ArrayListstringToArray(String charc, String commas)
string To Array
if (charc.isEmpty()) {
    return new ArrayList<>();
String[] at = charc.split(commas);
ArrayList<String> atd = new ArrayList<>();
atd.addAll(Arrays.asList(at));
return atd;
ArrayListstringToArray(String inputVal, String delimiter)
string To Array
if (inputVal == null || inputVal.length() <= delimiter.length()) {
    return null;
if (inputVal.indexOf(delimiter) == 0) {
    inputVal = inputVal.substring(delimiter.length());
if (inputVal.indexOf(delimiter) == inputVal.length() - delimiter.length()) {
    inputVal = inputVal.substring(0, inputVal.length() - delimiter.length());
...
String[]stringToArray(String s)
string To Array
List<String> list = stringToList(s);
return list.toArray(new String[list.size()]);
ListstringToArray(String str, String separator)
Get an array from a string separated by movieFilenameSeparator
ArrayList<String> array = new ArrayList<String>();
if (str == null) {
    return array;
if (separator == null) {
    separator = ", ";
String[] res = str.split(separator);
...
byte[]stringToByteArray(String text, int length)
Parse a human readable string into a byte array, truncating or padding with zeros (if necessary) so the array has the specified length.
return Arrays.copyOf(text.getBytes(), length);