Q:

BufferedOutputStream.close() will let BufferedInputStream be closed?

It's my first time to socket program. 
My requirement is that android client asks a question and receive the answer from ubuntu server via socket. 
In my client side, I create both BufferedInputStream and BufferedInputStream from my socket.
Socket client = new Socket();
InetSocketAddress isa = new InetSocketAddress(my_host, 8888);
client.connect(isa, 10000);
inputStream = new BufferedInputStream(client.getInputStream());
outputStream = new BufferedOutputStream(client.getOutputStream());

I experience a strange behavior: As my client sends request by outputStream and call its close(), then call inputStream.read() will get java.net.SocketException: Socket is closed error. But my client.isConnected() still return true.
try {
  outputStream.write("who_are_you".getBytes());
  outputStream.flush();
  outputStream.close();  // inputStream will be invalid if I call this line.

  Log.i(TAG, "client: " + client.isConnected());  // client still return true
  byte[] b = new byte[1024];
  String data = "";
  int length;
  // I will receive java.net.SocketException: Socket is closed as I call below code
  while ((length = inputStream.read(b)) > 0)  // If length <= 0, it means exit.
  {
    Log.i(TAG, "receive message, length: " + length);
    data += new String(b, 0, length);
    Log.i(TAG, "receive message: " + data);
  }
} catch (java.io.IOException e) {
  Log.w(TAG, "socket connection fail");
  e.printStackTrace();
}

I know that I can avoid this if I do not call outputStream.close(). But I just very curious about why it happens? Is it a normal result?

A:

Closing either socket input stream or output stream will call close on the socket itself. So you don't need to close them unless you want to close the connection.
As for your check please refer to javadoc on Socket#isConnected() method (https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#isConnected())

public boolean isConnected()
Returns the connection state of the socket.
Note: Closing a socket doesn't clear its connection state, which means this method will return true for a closed socket (see isClosed()) if it was successfuly connected prior to being closed.

