1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram

  5. Delphifan Magazine
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

Http Get/Post

Discussion in 'Delphi Programming' started by AdminDF, Feb 14, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Code:
    public void getData(){ 
    BufferedReader in = null; 
    
    try{ 
    HttpClient client = new DefaultHttpClient(); 
    HttpGet request = new HttpGet("http://localhost/index.jsp"); 
    HttpResponse response = client.execute(request); 
    
    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 
    StringBuffer sb = new StringBuffer(""); 
    String line = ""; 
    String NL = System.getProperty("line.separator"); 
    while((line = in.readLine()) != null){ 
    sb.append(line + NL); 
    } 
    in.close(); 
    String page = sb.toString(); 
    
    Log.i(TAG, page);
    
    }catch(Exception e){ 
    Log.e(TAG,e.toString()) 
    }finally{ 
    if(in != null){ 
    try{ 
    in.close(); 
    }catch(IOException ioe){ 
    Log.e(TAG, ioe.toString()); 
    } 
    } 
    
    } 
    } 
    
    -------------------------------------------------------------------------------------
    
    public void postData(){ 
    BufferedReader in = null; 
    
    try{ 
    HttpClient client = new DefaultHttpClient(); 
    HttpPost request = new HttpPost("http://localhost/upload.jsp"); 
    
    List postParams = new ArrayList(); 
    postParams.add(new BasicNameValuePair("filename", "sss.mov")); 
    
    UrlEncodeFormEntity formEntity = new UrlEncodeFormEntity(postParams); 
    request.setEntity(formEntity); 
    
    HttpResponse response = client.execute(request); 
    
    in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); 
    StringBuffer sb = new StringBuffer(""); 
    String line = ""; 
    String NL = System.getProperty("line.separator"); 
    while((line = in.readLine()) != null){ 
    sb.append(line + NL); 
    } 
    in.close(); 
    String result = sb.toString(); 
    Log.i(TAG, result ); 
    
    }catch(Exception e){ 
    Log.e(TAG,e.toString()) 
    }finally{ 
    if(in != null){ 
    try{ 
    in.close(); 
    }catch(IOException ioe){ 
    Log.e(TAG, ioe.toString()); 
    } 
    } 
    
    } 
    }
     

Share This Page