精华内容
下载资源
问答
  • import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Random;import java.util.Scanner;public class Mobile {//中国移动public static final String[] CHINA_MOBILE...

    import java.io.File;

    import java.io.FileOutputStream;

    import java.io.IOException;

    import java.util.Random;

    import java.util.Scanner;

    public class Mobile {

    //中国移动

    public static final String[] CHINA_MOBILE = {

    "134", "135", "136", "137", "138", "139", "150", "151", "152", "157", "158", "159",

    "182", "183", "184", "187", "188", "178", "147", "172", "198"

    };

    //中国联通

    public static final String[] CHINA_UNICOM = {

    "130", "131", "132", "145", "155", "156", "166", "171", "175", "176", "185", "186", "166"

    };

    //中国电信

    public static final String[] CHINA_TELECOME = {

    "133", "149", "153", "173", "177", "180", "181", "189", "199"

    };

    /**

    * 生成手机号

    *

    * @param op 0 移动 1 联通 2 电信

    */

    public static String createMobile(int op) {

    StringBuilder sb = new StringBuilder();

    Random random = new Random();

    String mobile01;//手机号前三位

    int temp;

    switch (op) {

    case 0:

    mobile01 = CHINA_MOBILE[random.nextInt(CHINA_MOBILE.length)];

    break;

    case 1:

    mobile01 = CHINA_UNICOM[random.nextInt(CHINA_UNICOM.length)];

    break;

    case 2:

    mobile01 = CHINA_TELECOME[random.nextInt(CHINA_TELECOME.length)];

    break;

    default:

    mobile01 = "op标志位有误!";

    break;

    }

    if (mobile01.length() > 3) {

    return mobile01;

    }

    sb.append(mobile01);

    //生成手机号后8位

    for (int i = 0; i < 8; i++) {

    temp = random.nextInt(10);

    sb.append(temp);

    }

    return sb.toString();

    }

    public static void main(String[] args) throws IOException {

    Scanner scan = new Scanner(System.in);

    System.out.println("请输入生成的手机号个数:");

    int number = scan.nextInt();

    Random random = new Random();

    StringBuilder sb = new StringBuilder();

    for (int i = 1; i <= number; i++) {

    int op = random.nextInt(3);//随机运营商标志位

    sb.append(createMobile(op));

    if (i % 10 == 0) {

    sb.append("\n");

    } else {

    sb.append("\t");

    }

    }

    //写入文件

    FileOutputStream fos = new FileOutputStream(new File("F:/mobile.txt"));

    fos.write(sb.toString().getBytes());

    fos.close();

    System.out.println(number + "个号码生成成功!");

    }

    }

    展开全文
  • 因为测试过程中需要不断用到不同的手机号码,加上本人有选择困难症,故此直接用代码生成随机号码,以免让自己犹豫应该输入哪个手机码号~觉得让自己随意选择号码跟给小孩取名的难度是一样一样的。java:package main;...

    因为测试过程中需要不断用到不同的手机号码,加上本人有选择困难症,故此直接用代码生成随机号码,以免让自己犹豫应该输入哪个手机码号~觉得让自己随意选择号码跟给小孩取名的难度是一样一样的。

    java:

    package main;

    import java.util.ArrayList;

    import java.util.Random;

    /**

    * @author 苏宝伢 E-mail:by.su@qq.com

    * @version 创建时间: 2017年6月6日 下午4:04:58

    */

    public class MobileRandomNum {

    public static void main(String[] args) {

    // TODO Auto-generated method stub

    System.out.println(startMobileNo() + endMobileNo());

    }

    public static int startMobileNo(){

    int[] mobileStart = {139,138,137,136,135,134,159,158,157,150,151,152,188,130,131,132,156,155,133,153,189,180,177,176};

    Random r = new Random();

    ArrayList mobileList = new ArrayList<>();

    for(int i = 0;i

    mobileList.add(mobileStart[i]);

    }

    return mobileList.get(r.nextInt(mobileList.size()));

    }

    public static String endMobileNo(){

    Random r = new Random();

    String temp = "";

    for(int i=0;i<8;i++){

    temp += r.nextInt(10);

    }

    return temp;

    }

    }

    -----------------------------华丽的分割线--------------------------------------------------------

    R语言

    #生成手机号码前部分

    my.mobileNoStart

    return(c(139,138,137,136,135,134,159,158,157,150,151,152,188,130,131,132,156,155,133,153,189,180,177,176)[position])

    }

    #生成手机号码后部分

    my.mobileNoEnd

    endNo

    i

    for(k in endNo){

    i

    }

    #  i

    return(i)

    }

    #合成手机号码

    my.mobileNo.paste

    random.position

    mobileStartNo

    mobileEndNo

    gsub(" ","",paste(mobileStartNo,mobileEndNo))

    }

    print(my.mobileNo.paste())

    ------------Java实现随机生成姓名(姓氏我就挑了几个常见的)-----------------------------------------------

    package my_work_tool;

    import java.io.UnsupportedEncodingException;

    import java.util.Random;

    import java.util.List;

    import java.util.ArrayList;

    import java.util.regex.Matcher;

    import java.util.regex.Pattern;

    /**

    * @author 苏宝伢 E-mail:by.su@qq.com

    * @version 创建时间: 2017年6月8日 上午9:46:36

    */

    public class RandomName {

    public static void main(String[] args) throws UnsupportedEncodingException {

    String[] firstName = {"赵","钱","孙","李","周","吴","郑","王","冯","陈","卫","蒋","沈","韩","杨","朱","秦","许","何","吕","施","张","孔","曹","严","华","金","魏","陶","云","苏","范","彭","乐","于","时","傅","皮","齐","康","梅","林","刁","钟","徐","邱","骆"};

    System.out.print(firstName[randomPositon(firstName.length)]);

    System.out.println(hexIntToHexString("\\u" + randomName()));

    }

    public static int randomPositon(int length){

    Random r = new Random();

    return r.nextInt(length);

    }

    public static List allGB(){

    ArrayList resultList = new ArrayList<>();

    for(int i = 0x4E00;i <= 0x9FA5;i++){

    resultList.add(Integer.toHexString(i));

    }

    return resultList;

    }

    public static String randomName(){

    ArrayList resultList = (ArrayList)allGB();

    return resultList.get(randomPositon(resultList.size()));

    }

    public static String hexIntToHexString(String hexno){

    if(hexno.contains("\\u")) {

    StringBuffer buf = new StringBuffer();

    Matcher m = Pattern.compile("\\\\u([0-9A-Fa-f]{4})").matcher(hexno);

    while (m.find()) {

    try {

    int cp = Integer.parseInt(m.group(1), 16);

    m.appendReplacement(buf, "");

    buf.appendCodePoint(cp);

    } catch (NumberFormatException e) {

    }

    }

    m.appendTail(buf);

    String result = buf.toString();

    return result;

    }else{

    return null;

    }

    }

    }

    展开全文
  • java-生成手机号

    2020-11-18 09:44:52
    public static int getNum(int start,int end) { ... * 返回手机号码 */ private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(",")..
    
     public static int getNum(int start,int end) {
          return (int)(Math.random()*(end-start+1)+start);
      }
    
      /**
       * 返回手机号码 
       */
      private static String[] telFirst="134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(",");
      private static String getTel() {
          int index=getNum(0,telFirst.length-1);
          String first=telFirst[index];
          String second=String.valueOf(getNum(1,888)+10000).substring(1);
          String third=String.valueOf(getNum(1,9100)+10000).substring(1);
          return first+second+third;
      }
    
    展开全文
  • java随机生成手机号

    2020-12-22 09:15:29
    import java.util.Random; /** * @author 陈小哥cw * @date 2020/12/22 9:10 */ public class RandomPhoneNumber { //中国移动 public static final String[] CHINA_MOBILE = { "134", "135", "136", "137", ...
    package com.cw.bigdata.generatedata;
    
    import java.util.Random;
    
    /**
     * @author 陈小哥cw
     * @date 2020/12/22 9:10
     */
    public class RandomPhoneNumber {
        //中国移动
        public static final String[] CHINA_MOBILE = {
                "134", "135", "136", "137", "138", "139", "150", "151", "152", "157", "158", "159",
                "182", "183", "184", "187", "188", "178", "147", "172", "198"
        };
        //中国联通
        public static final String[] CHINA_UNICOM = {
                "130", "131", "132", "145", "155", "156", "166", "171", "175", "176", "185", "186", "166"
        };
        //中国电信
        public static final String[] CHINA_TELECOME = {
                "133", "149", "153", "173", "177", "180", "181", "189", "199"
        };
    
        /**
         * 生成手机号
         *
         * @param op 0 移动 1 联通 2 电信
         */
        public static String createMobile(int op) {
            StringBuilder sb = new StringBuilder();
            Random random = new Random();
            String mobile01;//手机号前三位
            int temp;
            switch (op) {
                case 0:
                    mobile01 = CHINA_MOBILE[random.nextInt(CHINA_MOBILE.length)];
                    break;
                case 1:
                    mobile01 = CHINA_UNICOM[random.nextInt(CHINA_UNICOM.length)];
                    break;
                case 2:
                    mobile01 = CHINA_TELECOME[random.nextInt(CHINA_TELECOME.length)];
                    break;
                default:
                    mobile01 = "op标志位有误!";
                    break;
            }
            if (mobile01.length() > 3) {
                return mobile01;
            }
            sb.append(mobile01);
            //生成手机号后8位
            for (int i = 0; i < 8; i++) {
                temp = random.nextInt(10);
                sb.append(temp);
            }
            return sb.toString();
        }
    
        public static void main(String[] args) {
            Random random = new Random();
            StringBuilder sb = new StringBuilder();
            for (int i = 1; i <= 10; i++) {
                int op = random.nextInt(3);//随机运营商标志位
                sb.append(createMobile(op));
                if (i % 10 == 0) {
                    sb.append("\n");
                } else {
                    sb.append("\t");
                }
            }
            System.out.println(sb.toString());
        }
    }
    
    
    展开全文
  • import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;import java.io.UnsupportedEncodingException;import java.util.Random;public class base1 {public static Strin...
  • 废话不多说了,直接给大家贴java代码了,代码有所注释,写的不好,还请各位大家多多关照。代码如下所示:package com.alibaba.uyuni.common.util;import java.util.Random;public class GeneratePassword {/*** 生成...
  • Java 随机生成手机号、用户名

    千次阅读 2019-02-22 19:35:40
    import java.util.HashMap; import java.util.Map;... * 随机生成中文姓名,性别,Email,手机号,住址 * @author X-rapido */ public class RandomValue { public static String base = "abcdef...
  • import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;import java.io.UnsupportedEncodingException;import java.util.Random;public class base1 {public static Strin...
  • 需求说明要求根据用户输入,生成相应组数的电话号码实现思路1、通过百度,获取对应真实世界中电话号码的头三位数2、...import java.util.Scanner;/*** @auther::9527* @Description: 随机生成电话号码* @program: s...
  • import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Random;import java.util.Scanner;public class Mobile {//中国移动public static final String[] CHINA_MOBILE...
  • 随机生成手机号java代码

    万次阅读 2017-10-27 20:06:58
    随机生成中文名、性别、手机号、住址、email的java代码package cn.sayyoo.test;import java.util.HashMap; import java.util.Map;/** * 随机生成中文姓名,性别,Email,手机号,住址 * @author X-rapido */ ...
  • (转)Java 随机生成手机号、用户名

    千次阅读 2018-12-17 10:35:56
    import java.util.HashMap; import java.util.Map;... * 随机生成中文姓名,性别,Email,手机号,住址 * @author X-rapido */ public class RandomValue { public static String base = "abcdefg...
  • /**** * * Project Name:recruit-helper-util * 随机数生成工具类,主要包括 * 中文姓名,性别,Email,手机号,住址 *@ClassName: RandomValueUtil *@date 2018年5月23日 下午2:11:12 * *@author youqiang.xiong *@...
  • Java 生成随机手机号,并写入数据库

    千次阅读 2018-09-07 17:40:21
    public int getNum(int start,int end) { return (int)(Math.random()*(end-start+1)+start); } ... * 返回手机号码 */ private String[] telFirst="158,138".split(","); private String getT...
  • 废话不多说了,直接给大家贴java代码了,代码有所注释,写的不好,还请各位大家多多关照。代码如下所示:package com.alibaba.uyuni.common.util;import java.util.Random;public class GeneratePassword {/*** 生成...
  • 主要介绍了Java随机生成姓名,手机号,住址代码示例,属于Java基础方面的内容,具有一定参考价值,需要的朋友可以了解下。
  • 因为测试过程中需要不断用到不同的手机号码,加上本人有选择困难症,故此直接用代码生成随机号码,以免让自己犹豫应该输入哪个手机码号~觉得让自己随意选择号码跟给小孩取名的难度是一样一样的。java:package main;...
  • import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStreamWriter;import java.io.UnsupportedEncodingException;import java.util.Random;public class base1 {public static Strin...
  • 主要介绍了Java随机密码生成并和邮箱、手机号匹配的相关资料,需要的朋友可以参考下
  • Java 手机验证码生成

    千次阅读 热门讨论 2017-05-14 21:01:26
    然后再判断用户输入的手机号是否正确,正确则生成订单信息入库。 ……2.实现…… 实现的思路是,1.发送二维码 2.验证二维码和redis中存放的是否一致 3.生成订单入库 1.发送二维码,其实是Java代码...
  • #生成手机号码前部分 my.mobileNoStart (position){  return(c(139,138,137,136,135,134,159,158,157,150,151,152,188,130,131,132,156,155,133,153,189,180,177,176)[position]) } #生成手机号码后部分 my....
  • Pattern类用于创建一个正则表达式,生成一个Pattern对象并且编译一个正则表达式,也可以说创建一个匹配模式,它的构造方法是私有的,不可以直接创建, 但可以通过Pattern.complie(String regex)简单工厂方法创建一个正则...
  • import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.util.Random;import java.util.Scanner;public class Mobile {//中国移动public static final String[] CHINA_MOBILE...
  • 该楼层疑似违规已被系统折叠隐藏此楼查看此楼}else{OrgItem tempOIT=(OrgItem)i;// float tempRowHeight=this.calcuRowHeight(tempOIT.OfficePhone.size(),tempOIT.OfficePhone.size(), 14.25f);...
  • import java.io.FileWriter;import java.io.IOException;import javax.swing.Spring;public class fikewriter { public static void main(String[] args)throws IOException{ System.out.println("he...
  • Java随机生成姓名、邮箱、手机号码

    万次阅读 2018-05-23 14:20:07
    不多废话,直接贴上源码 ... /**** * * Project Name:recruit-helper-util * &...随机数生成工具类,主要包括&...* 中文姓名,性别,Email,手机号,住址 * @ClassName: RandomValueUtil * @date...
  • 在数据分析分过程中经常会用到一些各种需求的数据,例如几十G大小的【手机号码】+【姓名】+【时间】的源数据,一般情况下的这种数据在开发阶段是拿不到的,只能自己手动生成,这里提供一个简单的思路。 package ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 417
精华内容 166
关键字:

java生成手机号

java 订阅