All pastes #2093530 Raw Edit

Exercice 6 + 7 Prog Web

public java v1 · immutable
#2093530 ·published 2011-11-10 10:54 UTC
rendered paste body
import java.net.MalformedURLException;import java.net.URL;import java.net.InetAddress;import java.net.UnknownHostException;public class Exo6 {	/**	 * @param args	 * @throws MalformedURLException 	 */	public static void main(String[] args) throws MalformedURLException {				String url = args[0];		decomposeURL(url);	}		public static void decomposeURL(String monurl) throws MalformedURLException{				URL lol = new URL(monurl);		String[] urlenkit = new String[8];		InetAddress ina = null,inal = null;		try {			ina = InetAddress.getByName(lol.getHost());			inal = InetAddress.getLocalHost();		} catch (UnknownHostException e) {			e.printStackTrace();		}				urlenkit[0] = "Protocole : "+lol.getProtocol();		urlenkit[1] = "Host : "+lol.getHost();		urlenkit[2] = "Path : "+lol.getPath();		urlenkit[3] = "Query : "+lol.getQuery();		urlenkit[4] = "Host name : "+ina.getHostName();		urlenkit[5] = "Host IP : "+ina.getHostAddress();		urlenkit[6] = "Local host name : "+inal.getHostName();		urlenkit[7] = "Local host IP : "+inal.getHostAddress();				for(int i=0;i<urlenkit.length;i++){			System.out.println(urlenkit[i]);		}	}}