-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSem2_T3_8.java
More file actions
28 lines (24 loc) · 839 Bytes
/
Sem2_T3_8.java
File metadata and controls
28 lines (24 loc) · 839 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.*;
// One file with random numbers and write Sorted in another file.
public class Sem2_T3_8 {
public static void main(String[] args) throws IOException {
BufferedReader br1 = new BufferedReader(new FileReader("D:\\number123.txt"));
BufferedWriter bw1 = new BufferedWriter(new FileWriter("D:\\sortednum123.txt"));
ArrayList<Integer> a = new ArrayList<>();
String l = br1.readLine();
while (l != null) {
int i = Integer.parseInt(l);
a.add(i);
l = br1.readLine();
}
Collections.sort(a);
for (Integer x : a) {
String r = x + " ";
bw1.write(r);
bw1.newLine();
bw1.flush();
}
br1.close(); bw1.close();
}
}