Java sample code

This sample contains Java example for connecting FRUITS API and JSON response

Sample code for connecting FRUITS API

URL url;
try {
    url = new URL("https://fwallet.net/fruits?requestType=getAccount&account=FRUITS-CNQB-X85V-HJNK-C2G5-CVJK-M6SQ");
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    con.setRequestMethod("GET");

    int status = con.getResponseCode();
    if (status == 200) {
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer content = new StringBuffer();
        while ((inputLine = in .readLine()) != null) {
            content.append(inputLine);
        }
        System.out.println(content); in .close();
    }
    con.disconnect();
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

JSON response

Last updated