maygapixel

Untitled

Feb 26th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class   ExtractIt
  2. {
  3.     private String url;
  4.    
  5.     public static void main(String[] args) {
  6.     String s =  ExtractIt.extractIt("http://example.com/files/public_files/test.zip");
  7.     String m =  ExtractIt.extractIt("www.abc.com/pub/*aaa.html");
  8.     System.out.println(s);
  9.     System.out.println(m);
  10.     }
  11.        
  12.     public static String extractIt (String url)
  13.     {
  14.         String[] s1  = url.split("/");
  15.         int i = s1.length; // s1เอามาหาindex
  16.         String s2 = s1[i-1];
  17.        
  18.         if(s2.startsWith(""))  
  19.          
  20.          return "_" + s2.substring(1);
  21.        
  22.         else
  23.          return s2;
  24.        
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment