Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- private static List<String> lines;
- private static List<String> clearList;
- private static Path path;
- public static void main(String[] args) throws IOException {
- getFile();
- for (String s:lines) {
- System.out.println(s);
- }
- System.out.println();
- /*deleteSpecialCharacters(lines);
- for (String s:lines) {
- System.out.println(s);
- }*/
- /*deleteSpecialCharacters1(lines, clearList);
- for (String s:lines) {
- System.out.println(s);
- }*/
- }
- private static void getFile() throws IOException {
- try {
- path = Paths.get("C:\\Users\\u1\\Desktop\\abcd.txt");
- lines = Files.readAllLines(path);
- } catch (IOException e) {
- System.out.println("File not found or Can't read file");
- }
- }
- private static void deleteSpecialCharacters(List<String> list) {
- for (String s : list) {
- s = s.replaceAll("[^a-zA-Zа-яА-Я]", " ");
- }
- }
- private static void deleteSpecialCharacters1(List<String> list, List<String> clearList) {
- String temp;
- for (String s : list) {
- temp = s.replaceAll("[^a-zA-Zа-яА-Я]", " ");
- clearList.add(temp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement