title: Java Equivalent Method to Test TCP Connection
body: <p>In C# to test if UltraVNC was up and running on a local machine I would do this</p>
  
  <pre><code>public static bool TestAvailablility(int port, string responseStartsWith)
          {
              bool toReturn = false;
  
              try
              {
                  using (TcpClient client1 = new TcpClient())
                  {
                      client1.ReceiveTimeout = 10000;
                      client1.SendTimeout = 10000;
                      client1.Connect("localhost", port);
  
                      using (NetworkStream stream = client1.GetStream())
                      {
                          Byte[] response = new Byte[4096];
                          Int32 bytes = 0;
                          string serverReturnString = null;
                          bytes = stream.Read(response, 0, response.Length);
                          serverReturnString = System.Text.Encoding.ASCII.GetString(response, 0, bytes);
  
                          Console.WriteLine("TestAvailablility: serverReturnString = {0}", serverReturnString);
                          if (serverReturnString.StartsWith(responseStartsWith, StringComparison.OrdinalIgnoreCase))
                          {
                              toReturn = true;
                          }
                      }
                  }
              }
              catch (Exception ex) // SocketException for connect, IOException for the read.
              {
                  Console.WriteLine("TestAvailable - Could not connect to VNC server.  Exception info: ", ex);
              }
  
              return toReturn;
          }
  </code></pre>
  
  <p>I'm new to Java so I'm hoping someone can help me with an equivalent method to preform this action. </p>