I am trying to make a cURL request to a website called oanda. I am trying to run the cURL request threw the command line with java code. The response will be in JSON. Code oanda gives you as an example of a cURL request goes as follows:
curl -i "https://api-fxtrade.oanda.com/v1/prices?instruments=EUR_USD"
I have downloaded the cURL software and saved the curl.exe program in my C drive. I have written this java code to try to test the cURL request in the command line:
import java.io.*;
public class FxTest {
public static void main(String[] args) throws Exception {
ProcessBuilder builder = new ProcessBuilder(
"cmd.exe", "/c", "cd \"C:\\curl https://www.youtube.com/");
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) { break; }
System.out.println(line);
}
}
}
When I run this I get this error:
The filename, directory name, or volume label syntax is incorrect.
I have also written java code for the command that oanda provides as a request:
import java.io.*;
public class FxTest {
public static void main(String[] args) throws Exception {
ProcessBuilder builder = new ProcessBuilder(
"cmd.exe", "/c", "cd \"C:\\curl -i \"https://api-fxtrade.oanda.com/v1/prices?instruments=EUR_USD\"");
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while (true) {
line = r.readLine();
if (line == null) { break; }
System.out.println(line);
}
}
}
When I run this I get the same error. If you could explain how this code is wrong and provide a link or example explaining how to fix it that would be awesome! Thank you for your Help!!!

New Topic/Question
Reply


MultiQuote


|