I have learned lots of suggestions to run curl in Java or its derivatives. For example, curl command in Java, using curl command in Java, etc.
Also, I have figured out how to fetch the metadata of a given resource using DOI. From this instruction, I am very interested in running this curl command using a small snippet in Java to handle the result.
Let's give an example. The URL is http://dx.doi.org/10.1016/j.immuni.2015.09.001.
Running curl command from a terminal
curl -LH "Accept: application/x-bibtex" http://dx.doi.org/10.1016/j.immuni.2015.09.001
The output looks like
@article{Biswas_2015,
    doi = {10.1016/j.immuni.2015.09.001},
    url = {https://doi.org/10.1016%2Fj.immuni.2015.09.001},
    year = 2015,
    month = {sep},
    publisher = {Elsevier {BV}},
    volume = {43},
    number = {3},
    pages = {435--449},
    author = {Subhra~K. Biswas},
    title = {Metabolic Reprogramming of Immune Cells in Cancer Progression},
    journal = {Immunity}
Running this curl command in Groovy
Recycling some codes sharing on this site, I have written the process as below.
Map result = [:]
String command = "curl -LH 'Accept: application/x-bibtex' http://dx.doi.org/10.1016/j.immuni.2015.09.001"
Process process = Runtime.getRuntime().exec(command)
InputStream stream = process.getInputStream()
result.put("data", stream.text)
process.destroy()
What I obtain is the whole page in HTML rather than a BibTeX formatted form as what is my expectation.
The question is: what am I doing wrong here? Are there any of you that have experienced with that issue?
 
    