I make a call to a server using Java in order to receive json information and I want to retrieve that information through a Rest Web Servie. Right now I have this code:
public class consult {
public static void consult1() the url that retrieves json);
InputStream response = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(response));
for (String line; (line = reader.readLine()) != null;) {
System.out.println(line);
}
reader.close();
}
This shows the Json perfectly on the console but how can I set the information into some variable so when I call this WS in my browser (/resources/consult/) shows the info according to this WS?
@Path("/consult")
public class ConsultJSON {
@GET
@Produces ("application/json")
public String getInfo() throws MalformedURLException, IOException {
return consult.consult1();
}