here is how
And the simple inner class
Authenticator.setDefault(new MyAuthenticator("user","password"));
URL url = new URL("http://localhost:5300/database?_query='for $a in collection('test')/types return $a'");
InputStream resultStream =url.openStream();
Are there any better way?class MyAuthenticator extends Authenticator {
private String username, password;
public MyAuthenticator(String username, String password) {
this.username = username;
this.password = password;
}
// This method is called when a password-protected URL is accessed
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password.toCharArray());
}
}