Skip to main content
deleted 2 characters in body; edited tags
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

encoding Encoding problem while accessing the url from javaAPI using Java

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");
  
    
    
    }

 
}

encoding problem while accessing the url from java

I was having a problem in accessing the contents of the url ,when i was trying to call the url from java application.I can access other sites through my program but not the stack exchange site. But i can call the url directly from the browser and get data. But i want the output from my program. this is my program and output is is encrypted form.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;

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");
  
    
    
    }

 
}

Encoding problem while accessing the API using Java

Trying to call an API URL from a Java application, I'm having problems accessing the contents of the URL.

I can access other sites through my program but not the Stack Exchange site. But I can call the URL directly from the browser and get data.

This is my program and output is in encrypted form. 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;

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");
    }
}
Source Link

encoding problem while accessing the url from java

I was having a problem in accessing the contents of the url ,when i was trying to call the url from java application.I can access other sites through my program but not the stack exchange site. But i can call the url directly from the browser and get data. But i want the output from my program. this is my program and output is is encrypted form.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;

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");
  
    
    
    }


}