-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaJavaApp.java
More file actions
28 lines (23 loc) · 803 Bytes
/
aJavaApp.java
File metadata and controls
28 lines (23 loc) · 803 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
import java.io.*;
import java.util.Random;
public class aJavaApp {
public static void main(String [] args) {
// The name of the file to open.
//String fileName = "/proc/textJavaApp.preloadtest";
String fileName = args[0] + "/textJavaApp.preloadtest";
try {
String data = "This is the text content random number=";
Random rand = new Random();
int nAtRandom = rand.nextInt(5000) + 1;
data += Integer.toString(nAtRandom);
data += "\n";
RandomAccessFile file = new RandomAccessFile(fileName,"rw");
file.seek(0);
file.write(file.getFD().toString().getBytes());
file.write(data.getBytes());
file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}