How to divide a line from a known sign to its end?

When working with a zip file, I have this method

 ZipEntry ze = zis.getNextEntry(); String str = ze.getName(); 

and as a result, the **dirName**/**fileName**.**extention** value is stored in the string str **dirName**/**fileName**.**extention**

I need to cut off **dirName** to get /**fileName**.**extention**

That is, the symbol / and everything after it ...

Those methods that I invented (such as decomposing into an array and already removing the unnecessary, etc.) method from it, seem to me very much through my head.

I looked through all the standard String methods and did not find anything suitable there either.

Although I understand that the task is simple (

How to do it?

    1 answer 1

    How about using substring ?

     String fileName = str.substring(str.lastIndexOf('/') + 1, str.length()); 
    • Yes thank you! It works ... I screwed it through split("/"); , but your version is clearly shorter - Aleksey Timoshchenko