How to return int as server response?

时间:2017-04-10 00:14:46

标签: java networking server

Is this the correct way to return an int from a server response?

public static int getRequest2(String url) {
    String intresponse = "";
    int result = Integer.parseInt(intresponse);
    try {
        intresponse = Request.Get(url).execute().returnContent().asString();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    return result;
}

static int urlr(){
    return getRequest2("http://random.com");
}

I'm used to return string response, I'm a little lost on how to convert it. I tried to convert the string into an int.

0 个答案:

没有答案