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
{
	public static void main (String[] args) throws java.lang.Exception
	{
		String uri = "https://p...content-available-to-author-only...e.com:25461/live/teste/1234/1224.m3u8";
		
		/* Validação com a classe URL */
		try {
			new URL(uri);
			
			System.out.println( uri.substring(uri.length() - 5) );
		} catch (MalformedURLException e) {
			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) );
		} catch (IndexOutOfBoundsException e) {
			System.out.println( "O tamqanho da URL é inválido" );
		}
	}
}