Java HttpURLConnection getErrorStream() Method

The getErrorStream() is the method of HttpURLConnection class. This method is used to get an error stream if the connection is disconnected. This method does not set the connection. If the connection is not established or server does not cause any error during establishing the connection, then this method will return null. Null is the default value in this method.

Syntax

Returns

This method returns an error stream if any, else it returns default if no error occurs.

Example 1

Test it Now

Output:

Error Stream : null
Connection disconnected

Example 2

Test it Now

Output:

Connection Established
Error Stream : null
Header field 1:0
Connection disconnected




Latest Courses