Last active
August 29, 2015 14:04
-
-
Save aarondai/45c2e62631bf361b638d to your computer and use it in GitHub Desktop.
Java: XMLRPC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) { | |
StringBuilder sb = new StringBuilder(); | |
String line = br.readLine(); | |
while (line != null) { | |
sb.append(line); | |
sb.append(System.lineSeparator()); | |
line = br.readLine(); | |
} | |
String everything = sb.toString(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.xmlrpc.*; | |
public class JavaServer { | |
public Integer sum(int x, int y) { | |
return new Integer(x + y); | |
} | |
public static void main(String[] args) { | |
try { | |
System.out.println("Attempting to start XML-RPC Server..."); | |
WebServer server = new WebServer(80); | |
server.addHandler("sample", new JavaServer()); | |
server.start(); | |
System.out.println("Started successfully."); | |
System.out.println("Accepting requests. (Halt program to stop.)"); | |
} catch (Exception exception) { | |
System.err.println("JavaServer: " + exception); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment