This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi all, Any help would be appreciated. My question concerns the split method in the String class. Let's pretend I have a sequence of Strings in a text file that are tabbed delimited. And some of the Strings are simply empty but are still delimited by a tab. For example, Hello [tab] how [tab] [tab] you [tab] ? (Obviously this person is a foreigner with bad grammar and forgot "are".) After reading this line in and converting it to a String object, I use the split method. My question is this: how does the split method handle the blank/empty string? What character data does it return? Because when I try to print the bytes of this, no bytes are printed. I have some follow up questions, but I'll wait for some answsers first.
You might want to try split("\t+"). This will treat multiple consecutive tabs as a single delimiter, and so the blank field will be skipped entirely. IF that's what you really want - quite possibly, it's not.