Here you can find the source of sendCommand(String host, Integer port, String cmd)
public static void sendCommand(String host, Integer port, String cmd) throws Exception
//package com.java2s; //License from project: Apache License import java.io.OutputStream; import java.net.Socket; public class Main { public static void sendCommand(String host, Integer port, String cmd) throws Exception { Socket socket = new Socket(host, port); OutputStream out = socket.getOutputStream(); out.write(cmd.getBytes());//from w w w. j av a 2 s . co m out.close(); socket.close(); } }