This content has been marked as final.
Show 1 reply
-
1. Re: Java transformation and rest api using Developer
Srini Veeravalli Nov 15, 2019 6:08 AM (in response to Luiz Evora)The below works fine for me at command prompt.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class Main {
public static void main(String[] args) throws Exception {
//System.out.println("Hello world!");
URL url = new URL("https://viacep.com.br/ws/24120191/json");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine); }
in.close();
}
}