//我寫的。。。希望對妳有用。。。
public class H1 {
public static void main(String args[]) throws IOException {
int read;
String outfilename = "c:\\1.txt";
File fout = new File(outfilename);
PrintWriter out = new PrintWriter(new FileWriter(fout));
for (int i = 0; i <= 10000; i++) {
read = (int) (Math.random() * (100 - 0 + 1) + 0);// 這是取範圍隨機數的模型。。。
out.print(read + "\n");
}
out.close();
try {
FileInputStream fis = new FileInputStream("c:\\1.txt");
InputStreamReader isr = new InputStreamReader(fis);
LineNumberReader lnr = new LineNumberReader(isr);
String s = null;
int i;
while ((s = lnr.readLine()) != null) {
i = Integer.parseInt(s);
System.out.println("The decimal read: " + i);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}