-2

I want to write java code to implement this curl command:

 curl --form "file=@7_018011.gif" --form "apikey=helloworld" --form   
 "language=por" https://api.ocr.space/Parse/Image >> m.txt

where @7_018011.gif is the name of the image i want user to input to send the request to a RESTFUL service. Where can i start ?

0

1 Answer 1

0

Where can i start ?

Start by reading the javadocs for Process and ProcessBuilder. Read the linked (duplicate) Q&A as well.

However, note that the >> m.txt is shell syntax, and you can't pass that as an argument if you run curl directly. In other words, some of the solutions to the linked Q&A are not directly applicable.

There are two alternatives:

  1. Run via a subshell; e.g. run this command:

      sh -c 'curl --form "file=@7_018011.gif" 
                  --form "apikey=helloworld" 
                  --form "language=por" 
                  https://api.ocr.space/Parse/Image >> m.txt'
    
  2. Implement code to write the output to "m.txt" in Java.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.