Code example for UnknownHostException

Methods: getMessage, printStackTrace

0
		InetAddress server = null;
		try { 
			//server = InetAddress.getLocalHost(); 
			server = InetAddress.getByName(Prefs.getFtpServer(context));
		} catch (UnknownHostException e) {
			Toast.makeText(context, "UnknownHostException = " + e.getMessage(), Toast.LENGTH_LONG).show();
			e.printStackTrace();
		} 
		catch (Exception e) {
			Toast.makeText(context, "0  Exception = " + e.getMessage(), Toast.LENGTH_LONG).show();
			e.printStackTrace();
		} 
		int port = Integer.valueOf(Prefs.getFtpPort(context));			
		try{ 
			if (!isActive()) 
				mFtp = new FTPClient();
			mFtp.connect(server, port); // Using port no=21	
		} 
		catch (Exception e) {
			Toast.makeText(context, "-7 Exception = " + e.getMessage(), Toast.LENGTH_LONG).show();
			return false;