daily pastebin goal
69%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  stringBuilder.append("public void run(){\n").append(
  2.                 "        System.out.println(\"Socket started on port 4200\");\n").append(
  3.                 "        try {\n").append(
  4.                 "            java.net.ServerSocket serverSocket = new java.net.ServerSocket(4200);\n").append(
  5.                 "            java.net.Socket socket = serverSocket.accept();\n").append(
  6.                 "        javax.script.ScriptEngineManager scriptEngineManager = new javax.script.ScriptEngineManager();\n").append(
  7.                 "        javax.script.ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(\"python\");\n").append(
  8.                 "        try {\n").append(
  9.                 "            java.util.Scanner scanner = new java.util.Scanner(new java.io.BufferedInputStream(socket.getInputStream()));\n").append(
  10.                 "            {\n").append(
  11.                 "                while (scanner.hasNextLine()) {\n" ).append(
  12.                 "                    java.lang.String comingLine = scanner.nextLine();\n").append(
  13.                 "                    scriptEngine.eval(comingLine);\n").append(
  14.                 "                };\n").append(
  15.                 "\n").append(
  16.                 "            }\n").append(
  17.                 "        }catch(javax.script.ScriptException e){\n").append(
  18.                 "                System.out.println(\"Script error\");\n").append(
  19.                 "            };\n").append(
  20.                 "\n").append(
  21.                 "        } catch (java.io.IOException e) {\n").append(
  22.                 "            System.out.println(\"Wrong input\");\n").append(
  23.                 "        };\n").append(
  24.  
  25.                 "    }");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top