zoukankan      html  css  js  c++  java
  • java随机生成数字字母混合密码工具类

    说明:只做记录,方便以后使用,只是不想重复造轮子

    package uti.home;
    
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    
    public class tt {
    
        public static void main(String[] args) throws IOException {
            
              File f = new File("C:\Users\HUAWEI\Desktop\data.txt");
              BufferedWriter bw= new BufferedWriter(new FileWriter("C:\Users\HUAWEI\Desktop\temp.txt"));
              BufferedReader br = new BufferedReader(new FileReader(f));
              String line =null;
              while((line=br.readLine())!=null) { 
                  if(!line.contains("<-")) {
                      line = line.concat("	->密码"+getpass(8)).concat("
    ");
                  }else {
                      line = line.concat("
    ");
                  }
                  bw.write(line); 
             } 
              bw.flush();
              bw.close();
             
            
        }
        public static String getpass(int nums) {
            StringBuffer sb = new StringBuffer();
            for(int i=0;i<nums/2;i++) {
                int num = (int) (Math.random() * 10);
                int numchar = (int) (Math.random() * 26);
                
                sb.append(num).append((char)(numchar+65));
            }
            return sb.toString();
        }
    }
  • 相关阅读:
    ubuntu的apt
    sudo命令
    MySQL导出数据到csv文件
    MySQL导出数据到文件报错
    git_backup.py gitlab项目备份
    java中图像与数组转换
    mongodb转elasticsearch
    impyla-0.14.2.2安装注意事项
    python3.7.3升级 with-openssl openssl-1.0.2a
    hadoop自带性能测试
  • 原文地址:https://www.cnblogs.com/g177w/p/13804244.html
Copyright © 2011-2022 走看看