-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomInput.java~
More file actions
34 lines (32 loc) · 1022 Bytes
/
Copy pathrandomInput.java~
File metadata and controls
34 lines (32 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.*;
import java.io.*;
public class NumberGen {
private int x, y, z;
private Random rand;
NumberGen(){
x = 0;
y = 0;
z = 0;
rand = new Random();
}
public void write(int count) throws IOException{
BufferedWriter writer = new BufferedWriter(new FileWriter("output.txt", true));
writer.write("" + count);
writer.append(System.getProperty("line.separator"));
for(int i = 0; i < count; i++){
x = rand.nextInt(500);
y = rand.nextInt(500);
z = rand.nextInt(500);
writer.append(x + " " + y + " " + z);
writer.append(System.getProperty("line.separator"));
}
writer.close();
}
public void delete(){
File output = new File("output.txt");
output.delete();
}
public static void main(String[] args) throws IOException {
NumberGen generator = new NumberGen();
generator.write(300);
//generator.delete();