今天遇到个需求,需要从0000001开始计数,代码如下:
public class phone {
public static void main(String[] args) throws IOException {
FileWriter writer = new FileWriter(new File("C:\\Users\\mohe\\Desktop\\1.csv"));
// int str =1000000;
int aa=1;
System.out.println();
for (int i =0;i<=5000000;i++){
int a=aa+i;
writer.write(new DecimalFormat("0000000").format(a)+"\n");
//格式化数字位数,缺的自动补全0后写入文件里,“\n”是换行符
}
writer.close();
}
}