Adalarasan Sachithanantham Adalarasan Sachithanantham -4 years ago 112
Java Question

How do we split the Date in the path?

we have the path and it contains like

"/folder1/folder2/folder3/folder4/2015-11-25/"
.
Sometimes the folder is increasing recursively.
How do we split the date alone in java, we have to pass the path in the SQL without using the date.

Required path is :
/folder1/folder2/folder3/folder4/

Answer Source

Take the path as a string and use a simple replaceAll() on it

String s = "/folder1/folder2/folder3/folder4/2015-11-25/";
System.out.println(s.replaceAll("\\d{4}-\\d{2}-\\d{2}/", ""));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download