package com.example.needs.util;
import java.io.FileWriter;
import java.io.IOException;
public class TextUtil {
public static void main(String[] args) throws IOException {
//输出流,写入到D:/Lianxi/zidian.txt文件,文件不存在会自己创建,已有内容会覆盖之前内容
FileWriter fileWriter = new FileWriter("D:/Lianxi/zidian.txt");
//定义一个手机号zd占位,
String zd = "";
//for循环遍历中间六位数的所有组合
for (int i = 0; i < 1000000; i++) {
if (i >= 100000) {
//String.valueOf(i),将变量i转化为字符串
zd = "178" + String.valueOf(i) + "79";
} else if (i >= 10000) {
zd = "1780" + String.valueOf(i) + "79";
} else if (i >= 1000) {
zd = "17800" + String.valueOf(i) + "79";
} else if (i >= 100) {
zd = "178000" + String.valueOf(i) + "79";
} else if (i >= 10) {
zd = "1780000" + String.valueOf(i) + "79";
} else
zd = "17800000" + String.valueOf(i) + "79";
//调用.write方法,写入进文件夹,\r\n换行
fileWriter.write(zd + "\r\n");
}
//清除缓存区域
fileWriter.flush();
//关闭输出
fileWriter.close();
}
}
java遍历输出手机号
最新推荐文章于 2023-04-23 20:07:44 发布