How to upload triples stored in a variable to virtuoso?

I have a string variable containing

"<http://qalara.com/product/10101110201> a <http://schema.org/Product>;<http://schema.org/color> "pink"."

the following triples .
How can write a java program to upload it to virtuoso without putting it into a file?

You have posted in the RDF4J Data Provider category thus does that mean you are using RDF4J ?

As if so and you don’t want to load RDF data from dataset files, then the RDF4J RepositoryConnection methods allows the addition of triples (subject. predicate , object) values directly and can be done with the Virtuoso RDF4J Provider.

Thus if your string variables is converted to triple values they could be inserted that way.