Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java - out.write

Tags:

java

file-io

I try to write this line in a text file:

graph[bgcolor=white, size="9", center=1, margin="0.5, 0.5"];

like this:

out.write("graph [bgcolor=white, size="+9+", center="+1+", margin="+0.5,0.5+"];");

but it returns me an error at margin="+0.5,0.5+"

How can I solve this?

Thanks

like image 749
user1632278 Avatar asked Dec 11 '25 17:12

user1632278


1 Answers

You have to escape the string. It will be better to use String.format() method.

String str="Hello \"World\"";
String strOut=String.format("graph[bgcolor=white, size=\"%s\", center=%s, margin=\"%s, %s\"]",9,1,0.5,0.5);
out.write(strOut);
like image 82
KV Prajapati Avatar answered Dec 14 '25 07:12

KV Prajapati