lundi 6 février 2017

Static randomization in short algorithm

I create a long binary database at random. The length of the database can exceed billions. So I want to solve this problem with a short random algorithm that provides the database every try.

public RandomizeBinaryBuilder(){
      Characters = "abcdefghijklmnopqrstuvwxyz";
            for(int asd = 0;asd<characters.length();asd++){
                for(int i=0;i<7000000;i++){                 
                    SB.append(""+rand.nextInt(2));
                }
                String result = SB.toString();
                SB.delete(0, SB.length());


                try (BufferedWriter bw = new BufferedWriter(new FileWriter("Database\\"+characters.charAt(asd)+".txt"))) {
                    bw.write(result);
                    System.out.println("Character \""+characters.charAt(asd)+".txt\" created.");
                } catch (IOException e) {
                    e.printStackTrace();
                }


            }
            System.out.println("Loop is finished!");
        }   




Aucun commentaire:

Enregistrer un commentaire