java - How to create multiple files, generating a random name for each file -


what i'm trying create lots of random files i'm lost. code below doesn't work, i'm wondering why doesn't work , can fix it.

import java.io.*; import java.util.*;  public class main {   public static void main(string arg[]){        random rn = new random();       int randn = 1+rn.nextint(999999990);       string i_s = integer.tostring(randn);        formatter file;         try{            for(int = 0; < 9999999; i++){               file = new formatter("%s.txt", i_s);           }       }       catch(exception ex){         system.err.println("error");       }    }  

}

by generating random numbers, may end creating / overwriting same file multiple times. have absolutely unique set, this:

    final int max = 9999999;      list<integer> list = new arraylist<integer>();      (int = 0; < max; i++) {         list.add(i);     }      collections.shuffle(list);      (int = 0; < max; i++) {         // create files here     } 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -