I have a JSON file and i am trying to deal with but the following error is appears:
Exception in thread \"main\" org.json.JSONException: A JSONObject
The answer is :
instead of JSONArray jsonarray1=new JSONArray(res.toString());
write like this
JSONArray jsonarray1=new JSONArray(res.asString());
You have to read the content of the file first, because the constructor of JSONArray needs the file-content and not the file-path.
new JSONObject(new JSONTokener(new FileInputStream(new File("path"), "UTF-8")));
new JSONObject(new JSONTokener(new FileReader("path")));
update You should use a filereader or specify the charset for the FileInputStream