-2

How can is send something to an OutputStream?

ProcessBuilder pb = new ProcessBuilder("java", "-jar", "something.jar");
Process p = pb.start();

OutputStream out = p.getOutputStream();

//Already tried this:
InputStream in = new ByteArrayInputStream(sb.toString().getBytes());
in.transferTo(out); //But this says: This method is undefined for the type: InputStream
khelwood
  • 55,782
  • 14
  • 81
  • 108
Givou
  • 17
  • 1

2 Answers2

0

wrap it with DataOutputStream class, then you can use the writeUTF() method to write string objects.

-1

Already found out:
For anyone who is looking

out.write("say hello".getBytes());
Givou
  • 17
  • 1
  • If you're going to be writing text to your output stream, it's best to wrap it in an `OutputStreamWriter` so that you don't have to keep calling `getBytes`. – Dawood ibn Kareem Apr 08 '21 at 18:57