Created
June 13, 2020 12:22
-
-
Save ajaypro/e844a3110d3848038d1136d159a18e15 to your computer and use it in GitHub Desktop.
sample of substringAfter method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private const val FILE_PATH = "/storage/emulated/0/DCIM/Gallery/erwfwet285d9cesdferqwrsdfsg7e3259f.mp4" | |
fun main() { | |
val extension = FILE_PATH.substringAfter(delimiter = ".", missingDelimiterValue = "Extension Not found") | |
println("File extension -> $extension") | |
} | |
// Output | |
File extension -> mp4 | |
Explanation: the above code successfully give you the mp4 extension name of the file. | |
But if we change the delimiter value to something which does not exist inside the source string | |
then the missingDelimiterValue will be returned which is Extension Not Found. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment