Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1.         String fileName = "Document.txt";
  2.        
  3.         File file = new File(fileName);
  4.         String para = "";
  5.        
  6.        
  7.         int threePlus = 0;
  8.         try{
  9.             Scanner scan = new Scanner(file);
  10.             while(scan.hasNextLine())
  11.             {
  12.                 para+=scan.nextLine();
  13.             }
  14.         }catch(Exception e)
  15.         {
  16.             e.printStackTrace();
  17.         }
  18.        
  19.         String words[] = para.split("\\s+");
  20.        
  21.         for(int i =0; i<words.length; i++)
  22.         {
  23.             words[i] = words[i].replace("[^\\w]"," ");
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement