Created
July 9, 2015 15:47
-
-
Save addam01/f5dbc57fca0cc315ea08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MVPJSONParse { | |
public static void Decode(){ | |
} | |
/* Helper function. put it in the same page, or in a library */ | |
protected static String downloadFile(String URL, String category) { | |
String data; | |
// to fill-in url content | |
StringBuilder builder = new StringBuilder(); | |
try { | |
// local objects declarations | |
data = URLEncoder.encode("category", "UTF-8") + "=" + URLEncoder.encode(category, "UTF-8"); | |
java.net.URL url = new URL(URL); | |
URLConnection conn = url.openConnection(); | |
conn.setDoOutput(true); | |
OutputStreamWriter wr = new OutputStreamWriter | |
(conn.getOutputStream()); | |
wr.write(data); | |
wr.flush(); | |
BufferedReader reader = new BufferedReader | |
(new InputStreamReader(conn.getInputStream())); | |
StringBuilder sb = new StringBuilder(); | |
String line = null; | |
// Read Server Response | |
while ((line = reader.readLine()) != null) { | |
sb.append(line); | |
break; | |
} | |
return sb.toString(); | |
} catch (Exception e) { | |
return "Exception: " + e.getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment