我就写的两个方法,LZ可以参考
- <font size="3">public static int randNumber(int n){
- return (int)Math.random()*n+1;
- }
- public static void saveNumber(File file,int number){
- BufferedWriter fw=new BufferedWriter(new FileWriter(file));
- int x=0;
- while(x<100)
- {
- fw.write((int)randNumber(number));
- fw.newLine();
- fw.flush();
- x++;
- }
- fw.close();
- }</font>
复制代码 |