Java string split with “.” (dot) [duplicate]

Why does the second line of this code throw ArrayIndexOutOfBoundsException?

String filename = "D:/some folder/001.docx";
String extensionRemoved = filename.split(".")[0];

While this works:

String driveLetter = filename.split("https://stackoverflow.com/")[0];

I use Java 7.

4 Answers
4

Leave a Comment