-
Notifications
You must be signed in to change notification settings - Fork 0
/
SetMatrix.java
58 lines (43 loc) · 1.08 KB
/
SetMatrix.java
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
public class SetMatrix{
static FileChannel file;
static int Values[][] = new int[2048][2048];
public static void main(String [] args){
/* Populate Array */
for (int i = 0; i < 2048; i++) {
for (int j = 0; j < 2048; j++) {
Values[i][j] = 5;
System.out.println(Values[i][j]);
}
}
try{
/* Create file */
file = new FileOutputStream("fc.txt").getChannel();
}
catch (IOException e){
e.printStackTrace();
}
/* Save Array to file */
storeFC(file, Values);
}
private static void storeFC(FileChannel file, int[][] QValue) {
try {
ByteBuffer buf = ByteBuffer.allocateDirect(4 * 2048 * 2048);
for (int i = 0; i < 2048; i++) {
for (int j = 0; j < 2048; j++){
buf.put(String.valueOf(QValue[i][j]).getBytes());
buf.put("\n".getBytes());
}
}
buf.flip();
file.write(buf);
buf.clear();
// file.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}