-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatrixConversion.java
45 lines (43 loc) · 1.3 KB
/
MatrixConversion.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.util.*;
import java.io.*;
public class New {
public static void main (String[] args) {
File f = new File("netmats.txt");
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(f));
Writer bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("matrix.txt"), "utf-8"));
String line = null;
int i = 0;
int j = 0;
while ((line = br.readLine()) != null) {
// line = line.trim();
String[] s = line.split("\\s+");
int k = 0;
while (k < s.length) {
while (j < 100) {
bw.write(i + " " + j + " " + s[k] + "\n");
k++;
j++;
}
j = 0;
i++;
}
}
bw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
if (br != null) {
br.close();
}
} catch (IOException e) {
e.printStackTrace();;
}
}
}
}