how to split a phrase into an array and call on those arrays

Good day guys I would like to ask for your help: I want to turn Folder (that user cab selects) into like:

String userFolder = "user storage access"
Then do the
String [] Tim = userstorageaccess.split
Then have like
String gn1 = Tim[0]
String gn2 = Tim[1]

But it throws an exception if I pick a single name folder cuz it expects a folder name that is two names long minimum, Idk how to tell it to not expect any array length, I want it to be able to make the array only as long as it needs. Cuz I only want to use one or two names out of name into strings.

Thank you

Read more here:

Content Attribution

This content was originally published by Kwaker at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: