1 18 package org.apache.axis2.util; 19 20 public class URL { 21 private String protocol; 22 private String host; 23 private int port = -1; 24 private String fileName; 25 26 public URL(String url){ 27 int start = 0; 28 int end = 0; 29 end = url.indexOf("://"); 30 if(end > 0){ 31 protocol = url.substring(0,end); 32 start = end + 3; 33 } 34 35 end = url.indexOf('/',start); 36 if(end > 0){ 37 String hostAndPort = url.substring(start,end); 38 fileName = url.substring(end); 39 int index = hostAndPort.indexOf(':'); 40 if(index>0){ 41 host = hostAndPort.substring(0,index); 42 port = Integer.parseInt(hostAndPort.substring(index+1)); 43 }else{ 44 host = hostAndPort; 45 } 46 }else{ 47 host = url; 48 } 49 50 51 } 52 55 public String getFileName() { 56 return fileName; 57 } 58 59 62 public String getHost() { 63 return host; 64 } 65 66 69 public int getPort() { 70 return port; 71 } 72 73 76 public String getProtocol() { 77 return protocol; 78 } 79 80 } 81 | Popular Tags |