try { Runtime rt = Runtime.getRuntime(); rt.exec("net send 192.168.2.100 "+a); InputStream inpStream = rt.getInputStream(); InputStream errStream = rt.getErrorStream(); StringBuffer strBuf = new StringBuffer(); int len; while ((len = inpStream.read(buf)) > 0) { strBuf.append("STDOUT-Info: "+new String(buf, 0, len)); } while ((len = errStream.read(buf)) > 0) { strBuf.append("Error: "+new String(buf, 0, len)); } System.out.println(strBuf.toString());}catch (IOException ex) { ex.printStackTrace();}finally { try { inpStream.close(); errStream.close(); } catch (Exception e) { e.printStackTrace(); }}