private String send4LetterWord(String cmd) throws IOException {
  Socket sock=new Socket(host,port);
  BufferedReader reader=null;
  try {
    OutputStream outstream=sock.getOutputStream();
    outstream.write(cmd.getBytes());
    outstream.flush();
    sock.shutdownOutput();
    reader=new BufferedReader(new InputStreamReader(sock.getInputStream()));
    StringBuilder sb=new StringBuilder();
    String line;
    while ((line=reader.readLine()) != null) {
      sb.append(line + "\n");
    }
    return sb.toString();
  }
  finally {
    sock.close();
    if (reader != null) {
      reader.close();
    }
  }
}

private String send4LetterWord ( String cmd ) throws IOException { Socket sock = new Socket ( host , port ) ; BufferedReader reader = null ; try { OutputStream outstream = sock . getOutputStream ( ) ; outstream . write ( cmd . getBytes ( ) ) ; outstream . flush ( ) ; sock . shutdownOutput ( ) ; reader = new BufferedReader ( new InputStreamReader ( sock . getInputStream ( ) ) ) ; StringBuilder sb = new StringBuilder ( ) ; String line ; while ( ( line = reader . readLine ( ) ) != null ) { sb . append ( line + "\n" ) ; } return sb . toString ( ) ; } finally { sock . close ( ) ; if ( reader != null ) { reader . close ( ) ; } } }
send 4 letter command to zookeeper server
