Skip to content

Instantly share code, notes, and snippets.

@hu2di
Created April 10, 2017 02:49
Show Gist options
  • Save hu2di/053729a41925a24ec0747c34be81157f to your computer and use it in GitHub Desktop.
Save hu2di/053729a41925a24ec0747c34be81157f to your computer and use it in GitHub Desktop.
Android: Get content form URL
private static String docNoiDung_Tu_URL(String theUrl) {
StringBuilder content = new StringBuilder();
try {
URL url = new URL(theUrl);
URLConnection urlConnection = url.openConnection();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
content.append(line + "\n");
}
bufferedReader.close();
} catch(Exception e) {
e.printStackTrace();
}
return content.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment