Generate octave query using java

76 views Asked by At

I have a complicated drawing procedure written in Octave. I want to call it from JAVA. So, I am generating some octave query using JAVA to call this draw function. However, this part of code does not seem to me right:

String line = "draw('" + header + "','" + title + "'," + Arrays.toString(y1) + "," + Arrays.toString(y2) + "');";

Here, it is very hard to read because of the ' and "s.

Is there any other better way to do it?

1

There are 1 answers

0
Malcolm On

There is! Try String.format:

String line = String.format("draw('%s', '%s', '%s', '%s');", header, title, Arrays.toString(y1), Arrays.toString(y2));