0

I'm setting up a new web application with React.js Node.js and MongoDB. I'm getting data from the client side which sends the data to the server side. On the server side, I'm creating a file that contains the data that was entered on the client side. Now I find it difficult to find to send the same file to Java code\class\file where there is a function that needs to get the same file and run a certain calculation. Anyone knows a way to do this?

router.post('/name',(req,res)=>
{

    nameCounter++
    const fileData = new Uint8Array(Buffer.from(req.body.byName));
    fs.writeFile('byNameDataFile.'+nameCounter+'.txt', fileData, (err) => {
        if (err) throw err;
        console.log('byNameDataFile file has been saved!');
      }); 
})

I need to send 'byNameDataFile' to the Java file and run it with a specific function.

Gama11
  • 31,714
  • 9
  • 78
  • 100
MishaOk
  • 1
  • 5
  • maybe this is the same issue as this: https://stackoverflow.com/questions/18815734/how-to-call-java-program-from-nodejs – Dan Peebles Jun 04 '19 at 12:56
  • check out this https://stackoverflow.com/questions/12892195/how-to-run-a-jar-file-with-node-js-child-process-api – Rahul Patil Jun 04 '19 at 12:56
  • @DanPeebles, not exactly the same, I need for example to send file.txt with the string 'hello world' to a specific java function inside a .java file. This function will get the 'hello world' string and calculate something. – MishaOk Jun 04 '19 at 13:10

0 Answers0