I do not think you can do this with the built-in split method. So you have two options:
1) Make your own split
2) Iterating through the array after calling split and deleting empty elements
If you make your own split, you can simply combine these two options
public List<String> split(String inString) { List<String> outList = new ArrayList<>(); String[] test = inString.split("/"); for(String s : test) { if(s != null && s.length() > 0) outList.add(s); } return outList; }
or you can simply check if the separator is in the first position before you call split and ignore the first character if this happens:
String delimiter = "/"; String delimitedString = "/Test/Stuff"; String[] test; if(delimitedString.startsWith(delimiter)){
Hunter McMillen Feb 22 2018-12-12T00: 00Z
source share