Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl -u username:password https://example.com/xyz/abc
- String username="myusername";
- String password="mypassword";
- String url="https://www.example.com/xyz/abc";
- String[] command = {"curl", "-u" ,"Accept:application/json", username, ":" , password , url};
- ProcessBuilder process = new ProcessBuilder(command);
- Process p;
- try
- {
- p = process.start();
- BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
- StringBuilder builder = new StringBuilder();
- String line = null;
- while ( (line = reader.readLine()) != null) {
- builder.append(line);
- builder.append(System.getProperty("line.separator"));
- }
- String result = builder.toString();
- System.out.print(result);
- }
- catch (IOException e)
- { System.out.print("error");
- e.printStackTrace();
- }
- String[] command = {"curl", "-u" ,"Accept:application/json", username, ":" , password , url};
- String[] command = {"curl", "-H", "Accept:application/json", "-u", username+":"+password , url};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement