本文整理汇总了Java中java.net.URL.getHost方法的典型用法代码示例。如果您正苦于以下问题:Java URL.getHost方法的具体用法?Java URL.getHost怎么用?Java URL.getHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URL
的用法示例。
在下文中一共展示了URL.getHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHostName
import java.net.URL; //导入方法依赖的package包/类
/**
* Gets the host name from the repositoryURL
*
* @return The host name. An empty string if not connected. Never <code>null</code>.
*/
public String getHostName() {
if (git != null) {
Config storedConfig = git.getRepository().getConfig();
// TODO How we should react when there are multiple remote repositories???
String url = storedConfig.getString("remote", "origin", "url");
if (url == null) {
Set<String> remoteNames = git.getRepository().getRemoteNames();
url = storedConfig.getString("remote", remoteNames.iterator().next(), "url");
}
try {
URL u = new URL(url);
url = u.getHost();
return url;
} catch (MalformedURLException e) {
return "";
}
}
return "";
}
示例2: FtpURLConnection
import java.net.URL; //导入方法依赖的package包/类
/**
* Same as FtpURLconnection(URL) with a per connection proxy specified
*/
FtpURLConnection(URL url, Proxy p) {
super(url);
instProxy = p;
host = url.getHost();
port = url.getPort();
String userInfo = url.getUserInfo();
if (userInfo != null) { // get the user and password
int delimiter = userInfo.indexOf(':');
if (delimiter == -1) {
user = ParseUtil.decode(userInfo);
password = null;
} else {
user = ParseUtil.decode(userInfo.substring(0, delimiter++));
password = ParseUtil.decode(userInfo.substring(delimiter));
}
}
}
示例3: updateMediaNotificationForTab
import java.net.URL; //导入方法依赖的package包/类
/**
* Send an intent to MediaCaptureNotificationService to either create, update or destroy the
* notification identified by tabId.
* @param tabId Unique notification id.
* @param mediaType The media type that is being captured.
* @param fullUrl Url of the current webrtc call.
*/
public static void updateMediaNotificationForTab(
Context context, int tabId, int mediaType, String fullUrl) {
if (!shouldStartService(context, mediaType, tabId)) return;
Intent intent = new Intent(context, MediaCaptureNotificationService.class);
intent.setAction(ACTION_MEDIA_CAPTURE_UPDATE);
intent.putExtra(NOTIFICATION_ID_EXTRA, tabId);
String baseUrl = fullUrl;
try {
URL url = new URL(fullUrl);
baseUrl = url.getProtocol() + "://" + url.getHost();
} catch (MalformedURLException e) {
Log.w(TAG, "Error parsing the webrtc url, %s ", fullUrl);
}
intent.putExtra(NOTIFICATION_MEDIA_URL_EXTRA, baseUrl);
intent.putExtra(NOTIFICATION_MEDIA_TYPE_EXTRA, mediaType);
context.startService(intent);
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:MediaCaptureNotificationService.java
示例4: openConnection
import java.net.URL; //导入方法依赖的package包/类
@Override
public HttpClientConnection openConnection(URL url) throws IOException {
Socket socket = "https".equalsIgnoreCase(url.getProtocol())
? SSLSocketFactory.getDefault().createSocket(url.getHost(), url.getPort() > 0 ? url.getPort() : 443)
: new Socket(url.getHost(), url.getPort() > 0 ? url.getPort() : 80);
return DefaultBHttpClientConnectionFactory.INSTANCE.createConnection(socket);
}
示例5: init
import java.net.URL; //导入方法依赖的package包/类
private void init(
String modelURL
) {
try
{
URL url = new URL( modelURL );
String hostName = url.getHost();
if( hostName.equalsIgnoreCase( BIMViewer.HOST_PARAM_MARKER ) )
{
hostName = getModelHostname();
_modelURL = url.getProtocol() + "://" + getModelHostname() + url.getPath();
}
else
{
_modelURL = modelURL;
}
}
catch (MalformedURLException e)
{
_modelURL = modelURL;
}
if( _attribClass == null ) _attribClass = "LcRevitData";
if( _attribName == null ) _attribName = "Element";
if( _paramClass == null ) _paramClass = "LcRevitData";
if( _paramName == null ) _paramName = "Guid";
}
示例6: getFileSystem
import java.net.URL; //导入方法依赖的package包/类
@Nullable
public JavaFileManager getFileSystem(URL url) {
String prefix = url.getProtocol() + "://" + url.getHost() + "/";
if(prefix2jfm.containsKey(prefix)) {
return prefix2jfm.get(prefix).get();
} else {
return null;
}
}
示例7: setURL
import java.net.URL; //导入方法依赖的package包/类
/**
* Sets new URL.
*
* @param url URL to show in this browser.
*/
public void setURL(final URL url) {
if (url == null) {
txtLocation.setText(null);
return;
}
class URLSetter implements Runnable {
private boolean doReload = false;
@Override
public void run() {
if (!SwingUtilities.isEventDispatchThread()) {
boolean sameHosts = false;
if ("nbfs".equals(url.getProtocol())) { // NOI18N
sameHosts = true;
} else {
sameHosts = (url.getHost() != null) && (browserImpl.getURL() != null) &&
(url.getHost().equals(browserImpl.getURL().getHost()));
}
doReload = sameHosts && url.equals(browserImpl.getURL()); // see bug 9470
SwingUtilities.invokeLater(this);
} else {
if (doReload) {
browserImpl.reloadDocument();
} else {
browserImpl.setURL(url);
}
}
}
}
rp.post(new URLSetter());
}
示例8: savePublishedEndpoint
import java.net.URL; //导入方法依赖的package包/类
public void savePublishedEndpoint(String protocol, String host, String port, String serviceSuffix) throws MalformedURLException {
URL hostUrl = new URL(host);
String endpointProtocol = HTTP_PROTOCOL;
if (HTTPS_PROTOCOL.equalsIgnoreCase(protocol)) {
endpointProtocol = HTTPS_PROTOCOL;
}
String webServiceEndpointUrl = endpointProtocol + "://" + hostUrl.getHost() + ":" + port + "/" + serviceSuffix;
Thucydides.getCurrentSession().put(WEB_SERVICE_ENDPOINT_URL_KEY, webServiceEndpointUrl);
LOGGER.info("Saved published endpoint URL is:" + webServiceEndpointUrl);
}
示例9: getJsonURL
import java.net.URL; //导入方法依赖的package包/类
private URL getJsonURL(URL url) throws MalformedURLException {
// Append ".json" to URL in appropriate location.
String result = url.getProtocol() + "://" + url.getHost() + url.getPath() + ".json";
if (url.getQuery() != null) {
result += "?" + url.getQuery();
}
return new URL(result);
}
示例10: concatenateURL
import java.net.URL; //导入方法依赖的package包/类
/**
* Concatenates the given {@link java.net.URL} and query.
*
* @param url URL to base off
* @param query Query to append to URL
* @return URL constructed
*/
public static URL concatenateURL(final URL url, final String query) {
try {
if (url.getQuery() != null && url.getQuery().length() > 0) {
return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "&" + query);
} else {
return new URL(url.getProtocol(), url.getHost(), url.getPort(), url.getFile() + "?" + query);
}
} catch (final MalformedURLException ex) {
throw new IllegalArgumentException("Could not concatenate given URL with GET arguments!", ex);
}
}
示例11: hostsEqual
import java.net.URL; //导入方法依赖的package包/类
@Override
protected boolean hostsEqual(URL u1, URL u2) {
final String host1 = u1.getHost();
final String host2 = u2.getHost();
if (host1 != null && host2 != null)
return host1.equalsIgnoreCase(host2);
else
return host1 == null && host2 == null;
}
示例12: getScaledImageURL
import java.net.URL; //导入方法依赖的package包/类
private static URL getScaledImageURL(URL url) {
try {
String scaledImagePath = getScaledImageName(url.getPath());
return scaledImagePath == null ? null : new URL(url.getProtocol(),
url.getHost(), url.getPort(), scaledImagePath);
} catch (MalformedURLException e) {
return null;
}
}
示例13: getInputStream
import java.net.URL; //导入方法依赖的package包/类
private InputStream getInputStream(URL url) throws IOException {
if ("file".equalsIgnoreCase(url.getProtocol())) {
// Compatibility notes:
//
// Code changed from
// String path = url.getFile().replace('/', File.separatorChar);
// return new FileInputStream(path);
//
// The original implementation would search for "/tmp/a%20b"
// when url is "file:///tmp/a%20b". This is incorrect. The
// current codes fix this bug and searches for "/tmp/a b".
// For compatibility reasons, when the file "/tmp/a b" does
// not exist, the file named "/tmp/a%20b" will be tried.
//
// This also means that if both file exists, the behavior of
// this method is changed, and the current codes choose the
// correct one.
try {
return url.openStream();
} catch (Exception e) {
String file = url.getPath();
if (url.getHost().length() > 0) { // For Windows UNC
file = "//" + url.getHost() + file;
}
if (debugConfig != null) {
debugConfig.println("cannot read " + url +
", try " + file);
}
return new FileInputStream(file);
}
} else {
return url.openStream();
}
}
示例14: buildNewURL
import java.net.URL; //导入方法依赖的package包/类
private URL buildNewURL(URL base, String file) throws MalformedURLException {
return new URL(base.getProtocol(), base.getHost(), file);
}
示例15: BIMModelSpec
import java.net.URL; //导入方法依赖的package包/类
BIMModelSpec(
String locationName,
String location,
String binding,
MboRemote model
)
throws RemoteException,
MXException
{
_locationName = locationName;
_location = location;
_binding = binding;
_modelId = model.getLong( FIELD_BUILDINGMODELID );
setTitle( model.getString( BuildingModel.FIELD_TITLE ) );
_description = model.getString( BuildingModel.FIELD_DESCRIPTION );
_assetView = model.getString( BuildingModel.FIELD_ASSETVIEW );
_lookupView = model.getString( BuildingModel.FIELD_LOOKUPVIEW );
_locationView = model.getString( BuildingModel.FIELD_LOCATIONVIEW );
_attribClass = model.getString( BuildingModel.FIELD_ATTRIBUTECLASS );
_attribName = model.getString( BuildingModel.FIELD_ATTRIBUTENAME );
_paramClass = model.getString( BuildingModel.FIELD_PARAMCLASS );
_paramName = model.getString( BuildingModel.FIELD_PARAMNAME );
_siteId = model.getString( BuildingModel.FIELD_SITEID );
_workOrderView = model.getString( BuildingModel.FIELD_WORKORDERVIEW );
if( !model.getMboValueData( BuildingModel.FIELD_SELMODE ).isNull() )
{
try
{
_selectionMode = Integer.parseInt( model.getString( BuildingModel.FIELD_SELMODE ) );
}
catch( Throwable t )
{ // Ignore
}
}
String modelURL = model.getString( BuildingModel.FIELD_URL );
try
{
URL url = new URL( modelURL );
String hostName = url.getHost();
if( hostName.equalsIgnoreCase( BIMViewer.HOST_PARAM_MARKER ) )
{
hostName = getModelHostname();
_modelURL = url.getProtocol() + "://" + getModelHostname() + url.getPath();
}
else
{
_modelURL = modelURL;
}
}
catch (MalformedURLException e)
{
_modelURL = modelURL;
}
if( _attribClass == null ) _attribClass = "LcRevitData";
if( _attribName == null ) _attribName = "Element";
if( _paramClass == null ) _paramClass = "LcRevitData";
if( _paramName == null ) _paramName = "Guid";
}