Here you can find the source of getFullyQualifiedDomainName(String unqualifiedHostname)
Parameter | Description |
---|---|
unqualifiedHostname | hostname to be fully qualified |
static String getFullyQualifiedDomainName(String unqualifiedHostname)
//package com.java2s; /*// w ww.j a va 2 s. com * Copyright 2017 LinkedIn Corp. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /** * Converts a hostname into a canonical hostname. * * @param unqualifiedHostname hostname to be fully qualified * @return canonical hostname that can be compared with DataNode.getHostname() */ static String getFullyQualifiedDomainName(String unqualifiedHostname) { if (unqualifiedHostname == null) { throw new IllegalStateException("Hostname cannot be null."); } else if (unqualifiedHostname.length() == 0) { throw new IllegalStateException("Hostname cannot be zero length."); } try { return InetAddress.getByName(unqualifiedHostname).getCanonicalHostName().toLowerCase(); } catch (UnknownHostException e) { throw new IllegalStateException("Host (" + unqualifiedHostname + ") is unknown so cannot determine fully qualified domain name."); } } }