• Post Reply Bookmark Topic Watch Topic
  • New Topic

Format Long Value  RSS feed

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,
I m writing a java program to get the sequence of number if the from no and to num is given

example
if i give from 1 to 10
the o/p is:
1
2
3
4
5
6
7
8
9
10
this works fine but whn i enter 0001 to 0010
the o/p is same as of the above.
bt i wan to display the value as follows:
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
The sample program as follows:
import java.io.*;

public class Generator{

public static void main(String args[])
{
long arg1=Long.parseLong(args[0]);
long arg2=Long.parseLong(args[1]);


try {
BufferedWriter out = new BufferedWriter(new FileWriter("generate.csv"));
for(long i=arg1;i<=arg2;i++){

out.write("\""+i+"\"");
out.write("\r\n");
}
out.close();
} catch (IOException e) {
}



}
}

any suggestions?

Thanks in advance
Santhosh
 
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the Formatter class in the java.util package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!