Skip to content
Advertisement

Why is the useDelimiter works like that?

I have been trying to read a folder that contains any text files like this:

JavaScript

I was doing some tests and for some reason when I use the useDelimeter to ignore or make the commas disappear, I encounter to a problem. I will show the code first:

JavaScript

What I expect when the console prints the arrayList at position 3 is:

JavaScript

But instead of that it prints:

JavaScript

When I change the position to number 4 it prints: TOR (Which is the name of a team).

Advertisement

Answer

You defined your delimiter as ,, meaning that the newline is no longer the delimiter. To get the behavior you expect, you could use a regex where either a , or a newline character are considered as delimiters:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement