코딩 테스트에서 마침표 . 를 갖고 split을 했더니 계속 안됐다.
온라인 에디터를 사용해서 그런 것인줄 알았는데 그게 아니라 split("\\.")으로 했어야 했다.
스택오버플로우에서 찾아보니 특수문자여서 그렇다고 한다. 심지어 \.으로 인식이 안됐다.
역슬래쉬+역슬래쉬+마침표 -> 이렇게 split해야 된다.
stackoverflow.com/questions/14833008/java-string-split-with-dot
Java string split with "." (dot)
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
stackoverflow.com
'study > java' 카테고리의 다른 글
객체가 담긴 List 정렬 - stream을 활용해서 복잡한 정렬하기. (0) | 2021.05.13 |
---|---|
엉터리 정리 - map(), orElseGet() (0) | 2021.04.08 |
엉터리 정리 - java.util.Optional<T> (0) | 2021.03.25 |
자바/JAVA JAR (0) | 2021.03.15 |
자바/JAVA 스트림(Stream) (0) | 2021.03.13 |