Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static JSONObject getJSONObjectFromURL(String urlString) throws IOException, JSONException, MalformedURLException, ProtocolException {
- HttpURLConnection urlConnection = null;
- URL url = new URL(urlString);
- urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setRequestMethod("GET");
- urlConnection.setReadTimeout(10000 /* milliseconds */ );
- urlConnection.setConnectTimeout(15000 /* milliseconds */ );
- urlConnection.setDoOutput(true);
- urlConnection.connect();
- int statusCode = urlConnection.getResponseCode();
- System.out.println("CODIGOOOOOOOO:"+statusCode);
- BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
- StringBuilder sb = new StringBuilder();
- String line;
- while ((line = br.readLine()) != null) {
- sb.append(line + "n");
- }
- br.close();
- String jsonString = sb.toString();
- System.out.println("JSON: " + jsonString);
- return new JSONObject(jsonString);
- }
- java.io.FileNotFoundException: http://192.168.0.12/projeto/Cadastrarformularios.php?json=[{"Modalidade":"Presencial","Unidade":"belem","Email":"1@d.com","CPF":"1","Sobrenome":"sobrenome","Fone":"1","Cod_Consultor":"1001","Data_Cadastro":"2017-11-18 22:49:40","Curso":"autonomia","Nome":"1","Celular":"1"}]
Add Comment
Please, Sign In to add comment