Search code examples
javaandroidkotlinretrofituri

How can i get the filename from a string type link


With Retrofit, I get the url data in string data type, but I need the file name inside the url, how can I get it?

I've visited many websites but I couldn't find any results about it.


Solution

  • Try this in Kotlin

    url.substringAfterLast("/").substringBeforeLast(".")