Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void doHTTP(){
- StringBuffer chaine = new StringBuffer("");
- try{
- String urlString = "http://www.vigshakri.com/demo2.php?userid=vinayaga&username=shanmuga&pass=krishna";
- URL url = new URL(urlString);
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
- urlConnection.setDoInput(true);
- urlConnection.setDoOutput(true);
- urlConnection.connect();
- if(urlConnection.getResponseCode()==200)
- {
- Toast.makeText(getBaseContext(),"200", Toast.LENGTH_LONG).show();
- BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- StringBuilder stringBuilder = new StringBuilder();
- String line = null;
- while ((line = reader.readLine()) != null)
- {
- stringBuilder.append(line + "\n");
- }
- Toast.makeText(getBaseContext(),stringBuilder.toString(), Toast.LENGTH_LONG).show();
- }
- } catch (Exception e) {
- TextView textView = (TextView)findViewById(R.id.textView);
- textView.setText(e.getMessage().toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement