class Ideone
{
{
String line
= "word1|word2||||word3||word4|"; String[] parts
= line.
split("\\|+"); for (int i = 0; i < parts.length; i++) {
}
}
}
Y2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyBsaW5lID0gIndvcmQxfHdvcmQyfHx8fHdvcmQzfHx3b3JkNHwiOwoJCVN0cmluZ1tdIHBhcnRzID0gbGluZS5zcGxpdCgiXFx8KyIpOwoJCWZvciAoaW50IGkgPSAwOyBpIDwgcGFydHMubGVuZ3RoOyBpKyspIHsKCQkJU3lzdGVtLm91dC5wcmludGxuKHBhcnRzW2ldKTsKCQl9Cgl9Cn0=