To builds the Rest end point by accepting the base url and api url,we create the buildEndpoint() method.
- First we create the StringBuilder object.
- From append method we added the base URL and api URL.
- To return URL in string type,convert stringBuilder into String from toString() method.
public class Test {
// baseUrl: javatechnote.com
// apiUrl:- /spring-boot/
private String buildEndpoint(String apiUrl) {
StringBuilder sb = new StringBuilder();
sb.append(baseUrl);
sb.append(apiUrl);
return sb.toString();
}
}