You will be redirected to our new website in 5 seconds...
If you are not automatically taken to our new web site,
please click on the hyperlink :
http://jodd.org
Jodd
build: 309
updated: Jun 17 2008
 

SourceForge.net Logo

freebsd  Support this project

home Home | download | home Contact | SourceForge | File Releases releases | News news |  
Printf

Remember C and sprintf? That was a long time ago:) That function was very useful, so here is Java version (enhanced a bit). It is easy to use and fast. Formatting is specified in a string, as in C.

Printf.str("%+i", 173);		// +173
Printf.str("%04d", 1);		// 0001
Printf.str("%f", 1.7);		// 1.700000
Printf.str("%1.1f", 1.7);	// 1.7
Printf.str("%.4e", 100.1e10);	// 1.0010e+012
Printf.str("%G", 1.1e13);	// 1.1E+013
Printf.str("%l", true);		// true
Printf.str("%L", 123);		// TRUE
Printf.str("%b", 13);		// 1101
Printf.str("%,b", -13);		// 11111111 11111111 11111111 11110011
Printf.str("%#X", 173);		// 0XAD
Printf.str("%,x", -1);		// ffff ffff
Printf.str("%s %s", new String[]{"one", "two"});	// one two