Java HTTP Port Find sendCommand(final String command, final int monitorPort)

Here you can find the source of sendCommand(final String command, final int monitorPort)

Description

send Command

License

Apache License

Declaration

public static String sendCommand(final String command, final int monitorPort) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;

public class Main {
    public static String sendCommand(final String command, final int monitorPort) throws IOException {
        try (Socket socket = new Socket("127.0.0.1", monitorPort);
                BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))) {
            writer.write(command);/*  w  w  w  . java  2 s  . co m*/
            writer.newLine();
            writer.flush();
            return reader.readLine();
        }
    }
}

Related

  1. replace(final String host, final int port, final String user, final String program, final String relation, final String dataset, final String format)
  2. resolve(final String desc, final int defaultPort)
  3. safePort(final String port)
  4. searchPort(int number, int even, boolean stream)
  5. selectAvailablePort(int preferedPort)
  6. sendCommand(String host, Integer port, String cmd)
  7. serverIsUp(int port)
  8. ServerListening(String host, int port)
  9. serverListening(String host, int port)