25
P7.java
Normal file
25
P7.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class P7 {
|
||||
public static void main(String[] args) throws IOException {
|
||||
String filePath = "P7.in";
|
||||
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
lines.add(line + '\n');
|
||||
}
|
||||
|
||||
Collections.sort(lines); //sort
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
|
||||
for (String line: lines)
|
||||
writer.write(line);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user