Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. public void doHTTP(){
  2. StringBuffer chaine = new StringBuffer("");
  3.  
  4. try{
  5. String urlString = "http://www.vigshakri.com/demo2.php?userid=vinayaga&username=shanmuga&pass=krishna";
  6. URL url = new URL(urlString);
  7. HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
  8. urlConnection.setDoInput(true);
  9. urlConnection.setDoOutput(true);
  10. urlConnection.connect();
  11. if(urlConnection.getResponseCode()==200)
  12. {
  13. Toast.makeText(getBaseContext(),"200", Toast.LENGTH_LONG).show();
  14.  
  15. BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  16. StringBuilder stringBuilder = new StringBuilder();
  17. String line = null;
  18. while ((line = reader.readLine()) != null)
  19. {
  20. stringBuilder.append(line + "\n");
  21. }
  22.  
  23. Toast.makeText(getBaseContext(),stringBuilder.toString(), Toast.LENGTH_LONG).show();
  24.  
  25. }
  26.  
  27. } catch (Exception e) {
  28. TextView textView = (TextView)findViewById(R.id.textView);
  29. textView.setText(e.getMessage().toString());
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement