I have a requirement to call Unix command from Java
The code is as follows
String strCmd = "iconv -f "+ strSrcEncoding+" -t "+ strTgtEncoding + " <<< "+"\""+InputMessage+"\"";
String commands[] = {"bash","-c",strCmd};
Process proc = Runtime.getRuntime().exec(commands);
String strData = null;
// Get the error Stream
BufferedReader brStdError = new BufferedReader(new
InputStreamReader(proc.getErrorStream()));
StringBuilder sbError = new StringBuilder();
// read any errors from the attempted command
while ((strData = brStdError.readLine()) != null) {
sbError.append(strData);
}
if(sbError.toString().isEmpty())
return "success";
else
return "failure"+sbError.toString();
when i pass a large data am getting an error
"bash": java.io.IOException: error=7, Argument list too long
I tried using echo instead as below echo <> | iconv -f utf8 -t Cp930
But was getting the same error
Am i missing anything?