Code example for JSONArray

Methods: lengthoptString

     * @param defaultString the default to be used if the arg does not exist 
     * @return String with the retrieved value 
    private static String getArgument(JSONArray args, int position, String defaultString) {
        String arg = defaultString;
        if (args.length() > position) {
            arg = args.optString(position);
            if (arg == null || "null".equals(arg)) {
                arg = defaultString;
        return arg;
     * Downloads a file form a given URL and saves it to the specified directory. 
     * @param source        URL of the server to receive the file 
     * @param target            Full path of the file on the file system 
Contextual code suggestions in your IDE  Get Codota for Java