File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Storing integer 1 as a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Storing integer 1 as a string "00001" " Watch "Storing integer 1 as a string "00001" " New topic
Author

Storing integer 1 as a string "00001"

divya madala
Ranch Hand

Joined: Jan 10, 2001
Posts: 61
Can anybody help me here. I need to keep incrementing the integer in a loop and use the same integer as a string of 5 char.
For example if I am incrementing i from 1 to 20000.
My sequence should be printed as 00001,00002,00003......20000
Thanks,
Divya
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
Use DecimalFormat. It will insert leading 0's into your String.
DecimalFormat num = new DecimalFormat(�00000�);
num.format(yourNumber);
Angel Dobbs-Sciortino
[ November 05, 2003: Message edited by: Angel Dobbs-Sciortino ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing integer 1 as a string "00001"