fork(1) download
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5.  
  6.  
  7. class Pars {
  8.  
  9. public static void main(String[] args) {
  10.  
  11. String text = "";
  12.  
  13. System.in));
  14. System.out.println("Enter text: ");
  15. try {
  16. while ((text = inputText.readLine()) != null) {
  17. String newText = text.replaceAll("\\s+", " ")
  18. .replaceAll(" ,", ",").replaceAll(" \\.", "\\.")
  19. .replaceAll("\\s", " ");
  20. System.out.println(newText);
  21.  
  22. }
  23. } catch (IOException e) {
  24. e.printStackTrace();
  25. }
  26.  
  27. }
  28.  
  29. }
  30.  
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
Enter text: