Advertisement
Guest User

Untitled

a guest
Apr 14th, 2019
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. package AdvertisementMessage;
  2. import java.io.IOException;
  3. import java.lang.reflect.Array;
  4. import java.text.DecimalFormat;
  5. import java.util.*;
  6. import java.util.concurrent.CopyOnWriteArrayList;
  7. import java.util.stream.Collectors;
  8.  
  9. public class Main {
  10.  
  11.     public static void main(String[] args) throws IOException {
  12.  
  13.         Scanner scanner = new Scanner(System.in);
  14.  
  15.         List<String> data = Arrays.stream(scanner.nextLine().split("\\|+"))
  16.                 .collect(Collectors.toList());
  17.  
  18.         int n = data.size();
  19.  
  20.         while (n-- > 0) {
  21.             ArrayList<String> writer = new ArrayList<>();
  22.             writer.add(data.get(n));
  23.             String toPrint = writer.toString().replaceAll("[\\]\\[,]", "").trim();
  24.             toPrint = toPrint.replaceAll("\\s+", " ");
  25.             System.out.print(toPrint + " ");
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement