import java.net.URL;
import java.net.MalformedURLException;
import java.util.regex.Pattern;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String uri
= "https://p...content-available-to-author-only...e.com:25461/live/teste/1234/1224.m3u8";
/* Validação com a classe URL */
try {
System.
out.
println( uri.
substring(uri.
length() - 5) ); System.
out.
println( "URL Inválida" ); }
/* Trata o erro quando a string for menor que 5 caracteres */
try {
System.
out.
println( uri.
substring(uri.
length() - 5) ); System.
out.
println( "O tamqanho da URL é inválido" ); }
}
}
aW1wb3J0IGphdmEubmV0LlVSTDsKaW1wb3J0IGphdmEubmV0Lk1hbGZvcm1lZFVSTEV4Y2VwdGlvbjsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKLyogTmFtZSBvZiB0aGUgY2xhc3MgaGFzIHRvIGJlICJNYWluIiBvbmx5IGlmIHRoZSBjbGFzcyBpcyBwdWJsaWMuICovCmNsYXNzIElkZW9uZQp7CglwdWJsaWMgc3RhdGljIHZvaWQgbWFpbiAoU3RyaW5nW10gYXJncykgdGhyb3dzIGphdmEubGFuZy5FeGNlcHRpb24KCXsKCQlTdHJpbmcgdXJpID0gImh0dHBzOi8vcC4uLmNvbnRlbnQtYXZhaWxhYmxlLXRvLWF1dGhvci1vbmx5Li4uZS5jb206MjU0NjEvbGl2ZS90ZXN0ZS8xMjM0LzEyMjQubTN1OCI7CgkJCgkJLyogVmFsaWRhw6fDo28gY29tIGEgY2xhc3NlIFVSTCAqLwoJCXRyeSB7CgkJCW5ldyBVUkwodXJpKTsKCQkJCgkJCVN5c3RlbS5vdXQucHJpbnRsbiggdXJpLnN1YnN0cmluZyh1cmkubGVuZ3RoKCkgLSA1KSApOwoJCX0gY2F0Y2ggKE1hbGZvcm1lZFVSTEV4Y2VwdGlvbiBlKSB7CgkJCVN5c3RlbS5vdXQucHJpbnRsbiggIlVSTCBJbnbDoWxpZGEiICk7CgkJfQoJCQoJCS8qIFRyYXRhIG8gZXJybyBxdWFuZG8gYSBzd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