I'm trying to split text in a JTextArea using a regex to split the String by \n However, this does not work and I also tried by \r\n|\r|n and many other combination of regexes.
Code:
public void …
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("/")[0];
I use Java 7.
How to split the string "Thequickbrownfoxjumps" to substrings of equal size in Java.
Eg. "Thequickbrownfoxjumps" of 4 equal size should give the output.
["Theq","uick","brow","nfox","jump","s"]
Similar Question:
Split string into equal-length substrings in Scala