public static void reset() { // network@ip:10002 String address = source.substring(8, source.length() - 6); try { Socket server = new Socket(address, 9999); DataOutputStream out = new DataOutputStream(server.getOutputStream()); out.writeBytes("\r\n"); out.flush(); out.writeBytes("9\r\n"); out.flush(); } catch (Exception e) { System.out.println("Sorry I can't reset the device fro some reason: " + e); System.exit(1); } System.out.println("Issued reset command to " + address); }