Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. public class Main {
  2.  
  3. private static List<String> lines;
  4. private static List<String> clearList;
  5. private static Path path;
  6.  
  7.  
  8. public static void main(String[] args) throws IOException {
  9.  
  10. getFile();
  11. for (String s:lines) {
  12. System.out.println(s);
  13. }
  14. System.out.println();
  15.  
  16. /*deleteSpecialCharacters(lines);
  17.  
  18. for (String s:lines) {
  19. System.out.println(s);
  20. }*/
  21.  
  22. /*deleteSpecialCharacters1(lines, clearList);
  23.  
  24. for (String s:lines) {
  25. System.out.println(s);
  26. }*/
  27.  
  28. }
  29.  
  30. private static void getFile() throws IOException {
  31. try {
  32. path = Paths.get("C:\\Users\\u1\\Desktop\\abcd.txt");
  33. lines = Files.readAllLines(path);
  34. } catch (IOException e) {
  35. System.out.println("File not found or Can't read file");
  36. }
  37. }
  38.  
  39. private static void deleteSpecialCharacters(List<String> list) {
  40. for (String s : list) {
  41. s = s.replaceAll("[^a-zA-Zа-яА-Я]", " ");
  42. }
  43. }
  44.  
  45. private static void deleteSpecialCharacters1(List<String> list, List<String> clearList) {
  46. String temp;
  47. for (String s : list) {
  48. temp = s.replaceAll("[^a-zA-Zа-яА-Я]", " ");
  49. clearList.add(temp);
  50. }
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement