lottoclient.java

来自「Usefull sample codes for Java. Containt 」· Java 代码 · 共 46 行

JAVA
46
字号
import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.xmlrpc.*;

public class LottoClient {
    XmlRpcClient client;
    String server = "http://localhost";
    int port = 4404;
    
    public LottoClient() {
        try {
            client = new XmlRpcClient(server + ":" + port);
        } catch (MalformedURLException exception) {
            System.out.println("Bad URL: " + server + ":" + port);
        }
    }
    
    public void send(int plays, int win3, int win4, int win5, int win6) 
        throws IOException, XmlRpcException {
            
     Vector<Integer> params = new Vector<Integer>();
        params.add(plays);
        params.add(win3);
        params.add(win4);
        params.add(win5);
        params.add(win6);
        Boolean result = (Boolean) client.execute("lotto.sendResult", params);
    }
    
    public static void main(String[] arguments) {
        try {
            int plays = Integer.parseInt(arguments[0]);
            int win3 = Integer.parseInt(arguments[1]);
            int win4 = Integer.parseInt(arguments[2]);
            int win5 = Integer.parseInt(arguments[3]);
            int win6 = Integer.parseInt(arguments[4]);
            LottoClient lc = new LottoClient();
            lc.send(plays, win3, win4, win5, win6);
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
            exception.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?