0

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?

Sait
  • 19,045
  • 18
  • 72
  • 99

1 Answers1

0

There is! Try String.format:

String line = String.format("draw('%s', '%s', '%s', '%s');", header, title, Arrays.toString(y1), Arrays.toString(y2));
Malcolm
  • 41,014
  • 11
  • 68
  • 91