How to get text inbetween Digits and Blankline Using Java I Used Regex which shows
Exception in thread "main" java.lang.StringIndexOutOfBoundsException:
String index out of range: -1
Code Here:
List<String> file = Files.readAllLines(Paths.get(path),
StandardCharsets.UTF_8);
for(String v:file)
{
if(v!=null)
{
String answer = v.substring
(v.indexOf("//d")+1,v.indexOf("\\n"));
System.out.println(answer);
}
}
What is wrong with my regex?
My File :text.txt
fruits
1 Mango
Apple
Blank line
Veg
2 Onion
Tomato
Blank line
My Excepted Output is :
Mango
Apple
Onion
Tomato
But I Got Exception
Note : This File is Sample.And original File is Too Long
I mean blank line not new line