I was havingTrying to call an API URL from a problem inJava application, I'm having problems accessing the contents of the url ,when i was trying to call the url from java applicationURL.I
I can access other sites through my program but not the stack exchangeStack Exchange site. But iI can call the urlURL directly from the browser and get data. But i want the output from my program. this
This is my program and output is is in encrypted form.I I want to get in a normal format. import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.io.BufferedReader;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.io.BufferedReader;
public class URLServlet {
public static void main(String[] args) {
try {
URL urldemo = new URL("http://api.stackexchange.com/2.1/questions/1346?site=health.stackexchange.com&filter=withbody");
URLConnection yc = urldemo.openConnection();
yc.setDoOutput(true);
System.out.println(yc.getContent());
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}catch(Exception e) {
System.out.println(e);
}
System.out.println("hello world");
}
}