I want to be able to use both the comma and a new line as a delimeter for tokens. This would be for just commas:Tokens = new StringTokenizer(line,","); but how would I implement it to account for a new line as well?
I tried ",\n"and \n," but they do not work.
I am trying to extract the data from a text file that looks like this:
hello apple, tree, wolf eagle badge
I tested the following on an online java compiler.
The output I received:
The example parses the tokens for
,,,\n,\n,and\nThough if it really doesn't work for you, try using Split() as the link shown in the comments suggests as it allows regex to only allow,\nor\n,