fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. try {
  14. List<String> env = new ArrayList<>();
  15. env.add("ProtoMIOService--CRAU--Prod");
  16. env.add("FLO/Crau/EU/Gamma");
  17. for(String e : env) {
  18. e = e.replaceAll("--", "/");
  19. int last = e.lastIndexOf("/");
  20. System.out.println(e + " last index " + last);
  21. System.out.println(e.substring(0, last));
  22. System.out.println(e.substring(last+1, e.length()));
  23. }
  24. }catch(Exception e) {
  25. System.out.println("runtime error : " + e.getMessage());
  26. }
  27.  
  28. }
  29. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
ProtoMIOService/CRAU/Prod last index 20
ProtoMIOService/CRAU
Prod
FLO/Crau/EU/Gamma last index 11
FLO/Crau/EU
Gamma