ublic class BitlyExample{
public void run() throws Exception
{
try{
// String serviceURL = cartid;
URL myURL = new URL(serviceURL);
String basicAuth = "";
HttpsURLConnection myURLConnection = (HttpsURLConnection) myURL.openConnection();
//HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setRequestMethod("GET");
myURLConnection.setRequestProperty("Content-Type", "application/json");
myURLConnection.connect();
InputStream os = new BufferedInputStream(myURLConnection.getInputStream());
String requestString = "";
os.read(requestString.toString().getBytes());
int HttpResult = myURLConnection.getResponseCode();
if(HttpResult == HttpsURLConnection.HTTP_OK){
StringBuilder serviceResponse = new StringBuilder();
BufferedReader buffer = new BufferedReader(new InputStreamReader(myURLConnection.getInputStream(),"utf-8"));
String line = null;
while ((line = buffer.readLine()) != null) {
serviceResponse.append(line + "\n");
}
buffer.close();
boolean validationPass = true;
}
else{
throw new RuntimeException("HTTP Error Code : "+ HttpResult);
}
os.close();
myURLConnection.disconnect();
} catch (Exception e) {
throw new Exception(" Timeout Exception : "+ e.getMessage());
}
}
}