Name
URISyntaxException
Synopsis
Signals
that a string could not be parsed as a valid URI. getInput(
) returns the string that could not be parsed.
getReason( ) returns an error message.
getIndex( ) returns the character position at
which the syntax error occurred, if that information is available.
getMessage( ) returns a human-readable string that
includes the information from each of the other three methods.
This is a checked exception thrown by all the URI(
) constructors. If you are parsing a hard-coded URI that
you do not believe to contain any syntax errors, and wish to avoid
the checked exception, you can use the URI.create(
) factory method instead of the one-argument version of the
URI( )
constructor.
Figure 12-26. java.net.URISyntaxException
public class URISyntaxException extends Exception { // Public Constructors public URISyntaxException(String input, String reason); public URISyntaxException(String input, String reason, int index); // Public Instance Methods public int getIndex( ); public String getInput( ); public String getReason( ); // Public Methods Overriding Throwable public String getMessage( ); }
Thrown By
URI.{parseServerAuthority( ), URI(
)}, URL.toURI( )
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access