随机字母数字增量

时间:2014-10-12 12:15:32

标签: java

嘿,伙计们我制作了一个可以增加任何内容的程序 EX:abc123sx asd123213adsasd2。

但我对这些数字有疑问。 EX:001,1abc,abc1

String str1 = "EnterIDHere";
    String temp2 = new String();
    String Temp = new String();
    char[] charID = new char[str1.length()];
    charID = str1.toCharArray();
    str1.trim();        
    for(int intCtr1 = 0; intCtr1<str1.length();intCtr1++){
        if(Character.isDigit(charID[str1.length()-intCtr1-1])){
            Temp += charID[str1.length()-intCtr1-1];    
            if(Character.isLetter(charID[str1.length()-intCtr1-2])){
                break;
            }
        }
    }
    for(int intCtr1 = 0; intCtr1<str1.length();intCtr1++){
        if(Character.isLetter(charID[str1.length()-intCtr1-1])){
            temp2 += charID[str1.length()-intCtr1-1];
            if(Character.isDigit(charID[str1.length()-intCtr1-2])){
                break;
            }
        }
    }
    System.out.println("NumPart "+new StringBuilder(Temp).reverse().toString());
    System.out.println("LastPart "+new StringBuilder(temp2).reverse().toString());
    System.out.println("FrontPart "+str1.substring(0,(str1.length()-(temp2.length()+Temp.length()))));
    int Num = Integer.parseInt(new StringBuilder(Temp).reverse().toString());
    Num += 1;
            String Front = str1.substring(0,(str1.length()-(temp2.length()+Temp.length())));
    //System.out.println(str1.substring(0,(str1.length()-(temp2.length()+Temp.length())))+""+Num+""+temp2);
            strReturn = String.format("%s%d%s",Front,Num,temp2);

这是我的代码。 的修改

啊,我也忘了尾随零“00000001”它返回“1”。

0 个答案:

没有答案