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( )
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.