You can do a printf to anything that is an OutputStream with a PrintStream. Somehow like this, printing into a string stream:
PrintStream ps = new PrintStream(baos);
ps.printf("there is a %s from %d %s", "hello", 3, "friends");
System.out.println(baos.toString());
baos.reset(); //need reset to write new string
ps.printf("there is a %s from %d %s", "flip", 5, "haters");
System.out.println(baos.toString());
baos.reset();
The string stream can be created like this ByteArrayOutputStream:
ByteArrayOutputStream baos = new ByteArrayOutputStream();