forked from alexbeutel/FlexiFaCT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSaveColumns.java
45 lines (37 loc) · 1.06 KB
/
SaveColumns.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
import java.io.*;
import java.util.*;
import java.text.*;
public class SaveColumns {
public static void main(String[] args) {
for(int i = 0; i < args.length; i++){
System.out.println(i + " : " + args[i]);
}
int rank = Integer.parseInt(args[0]);
int N = Integer.parseInt(args[1]);
int offset = Integer.parseInt(args[2]);
String folder = args[3];
try {
System.out.println("Start");
BufferedWriter[] cols = new BufferedWriter[rank];
for(int j = 0; j < rank; j++) {
cols[j] = new BufferedWriter(new FileWriter(folder + "/col-" + j + ".txt",true));
}
System.out.println("Files Opened");
DataInputStream ds = new DataInputStream(System.in);
for(int i = 0; i < N; i++) {
for(int j = 0; j < rank; j++) {
float val = ds.readFloat();
cols[j].write( (i + offset * N) + "\t" + val + "\n");
}
}
System.out.println("Data Read");
for(int j = 0; j < rank; j++) {
cols[j].close();
}
System.out.println("Done");
} catch (IOException e) {
System.err.println("ERROR");
System.err.println(e.toString());
}
}
}