package com.roadway.httpinterface.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Send_Url_Get {
private String urlStr;
private URL url;
private HttpURLConnection url_con;
private String contentStr;
public void setUrlStr(String urlStr) {
this.urlStr = urlStr;
}
public String getContentStr() {
return contentStr;
}
private void setContentStr(String contentStr) {
this.contentStr = contentStr;
}
public void send_url() {
try {
StringBuilder temp = new StringBuilder();
url = new URL(urlStr);
url_con = (HttpURLConnection) url.openConnection();
url_con.setDoOutput(true);
url_con.setRequestMethod("GET");
url_con.getOutputStream().flush();
url_con.getOutputStream().close();
InputStream in = url_con.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(in));
while (rd.ready()){
temp.append(rd.readLine());
}
setContentStr(new String(temp));
} catch (Exception e) {
e.printStackTrace();
} finally {
if (url_con != null) {
url_con.disconnect();
}
}
}
}
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Send_Url_Get {
private String urlStr;
private URL url;
private HttpURLConnection url_con;
private String contentStr;
public void setUrlStr(String urlStr) {
this.urlStr = urlStr;
}
public String getContentStr() {
return contentStr;
}
private void setContentStr(String contentStr) {
this.contentStr = contentStr;
}
public void send_url() {
try {
StringBuilder temp = new StringBuilder();
url = new URL(urlStr);
url_con = (HttpURLConnection) url.openConnection();
url_con.setDoOutput(true);
url_con.setRequestMethod("GET");
url_con.getOutputStream().flush();
url_con.getOutputStream().close();
InputStream in = url_con.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(in));
while (rd.ready()){
temp.append(rd.readLine());
}
setContentStr(new String(temp));
} catch (Exception e) {
e.printStackTrace();
} finally {
if (url_con != null) {
url_con.disconnect();
}
}
}
}
package com.roadway.httpinterface.util;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Send_Url_Send {
private String urlStr;
private URL url;
private HttpURLConnection url_con;
private String response_content;
public void setUrlStr(String urlStr) {
this.urlStr = urlStr;
}
public String getResponse_content() {
return response_content;
}
private void setResponse_content(String response_content) {
this.response_content = response_content;
}
public void send_url(String mobile_number){
try{
url = new URL(urlStr);
url_con=(HttpURLConnection)url.openConnection();
url_con.setRequestMethod("POST");
url_con.setDoOutput(true);
String param="action=mobile &mobile ="+mobile_number;
url_con.getOutputStream().write(param.getBytes());
url_con.getOutputStream().flush();
url_con.getOutputStream().close();
InputStream in= url_con.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(in));
StringBuilder tempStr=new StringBuilder();
while (rd.ready()){
tempStr.append(rd.readLine());
}
setResponse_content(new String(tempStr));
} catch(Exception e){
e.printStackTrace();
}
finally{
if(url_con!=null)
url_con.disconnect();
}
}
}
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Send_Url_Send {
private String urlStr;
private URL url;
private HttpURLConnection url_con;
private String response_content;
public void setUrlStr(String urlStr) {
this.urlStr = urlStr;
}
public String getResponse_content() {
return response_content;
}
private void setResponse_content(String response_content) {
this.response_content = response_content;
}
public void send_url(String mobile_number){
try{
url = new URL(urlStr);
url_con=(HttpURLConnection)url.openConnection();
url_con.setRequestMethod("POST");
url_con.setDoOutput(true);
String param="action=mobile &mobile ="+mobile_number;
url_con.getOutputStream().write(param.getBytes());
url_con.getOutputStream().flush();
url_con.getOutputStream().close();
InputStream in= url_con.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(in));
StringBuilder tempStr=new StringBuilder();
while (rd.ready()){
tempStr.append(rd.readLine());
}
setResponse_content(new String(tempStr));
} catch(Exception e){
e.printStackTrace();
}
finally{
if(url_con!=null)
url_con.disconnect();
}
}
}