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.

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