ECMA Script: IOUtils toInputStream


since ‘org.apache.commons.*’ dependency was removed in 2020

this line will not work

var input =, "UTF-8");


How can I call Java function toInputStream in ECMA Script?


There a probably several ways to fix this. However, without knowing the context why you need an inputstream an answer might be might be sub optimal. So can you provide some more context on how you use the inputstream?

Hi @hilbrand,

I’m using

var response = HttpUtil.executeUrl(httpMethod, url , timeout);

for the connection to my web service.
But I need

var response = HttpUtil.executeUrl(httpMethod, url , input, contentType, timeout);

to pass the form parameters too. ‘input’ is a string variable, so I have to convert it with toInputStream(input) to a stream, because the 3rd parameter is of type stream

possible alternative

var stream = new"UTF-8"))
var response = HttpUtil.executeUrl(httpMethod, url , stream, contentType, timeout);

Ah make sense. I see you already found a solution with ByteArrayInputStream.