Created
April 10, 2017 02:49
-
-
Save hu2di/053729a41925a24ec0747c34be81157f to your computer and use it in GitHub Desktop.
Android: Get content form URL
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
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