本文整理了Java中java.net.URLConnection.getURL()
方法的一些代码示例,展示了URLConnection.getURL()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。URLConnection.getURL()
方法的具体详情如下:
包路径:java.net.URLConnection
类名称:URLConnection
方法名:getURL
[英]Returns the URL represented by this URLConnection.
[中]返回此URL连接表示的URL。
代码示例来源:origin: jenkinsci/jenkins
public NotTalkingToJenkinsException(URLConnection c) {
super("There's no Jenkins running at " + c.getURL().toString());
}
}
代码示例来源:origin: lingochamp/okdownload
DownloadUrlConnection(URLConnection connection, IRedirectHandler redirectHandler) {
this.connection = connection;
this.url = connection.getURL();
this.redirectHandler = redirectHandler;
}
代码示例来源:origin: stackoverflow.com
URLConnection con = new URL( url ).openConnection();
System.out.println( "orignal url: " + con.getURL() );
con.connect();
System.out.println( "connected url: " + con.getURL() );
InputStream is = con.getInputStream();
System.out.println( "redirected url: " + con.getURL() );
is.close();
代码示例来源:origin: redisson/redisson
/**
* Returns the URL.
*
* @return null if the class file could not be obtained.
*/
public URL find(String classname) {
try {
URLConnection con = openClassfile0(classname);
InputStream is = con.getInputStream();
if (is != null) {
is.close();
return con.getURL();
}
}
catch (IOException e) {}
return null;
}
代码示例来源:origin: nutzam/nutz
public static String dumpHeaders(URLConnection conn) {
StringBuilder sb = new StringBuilder();
Iterator<?> it = conn.getHeaderFields().keySet().iterator();
sb.append('\n');
sb.append("<HEADERS url=\"" + conn.getURL().toString() + "\">");
while (it.hasNext()) {
String name = (String) it.next();
sb.append('\n');
sb.append("[" + name + "]:");
sb.append(conn.getHeaderField(name));
}
sb.append('\n');
sb.append("</HEADERS>");
return sb.toString();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* If the server advertises CLI endpoint, returns its location.
* @deprecated Specific to {@link Mode#REMOTING}.
*/
@Deprecated
protected CliPort getCliTcpPort(URL url) throws IOException {
if (url.getHost()==null || url.getHost().length()==0) {
throw new IOException("Invalid URL: "+url);
}
URLConnection head = url.openConnection();
try {
head.connect();
} catch (IOException e) {
throw (IOException)new IOException("Failed to connect to "+url).initCause(e);
}
String h = head.getHeaderField("X-Jenkins-CLI-Host");
if (h==null) h = head.getURL().getHost();
String p1 = head.getHeaderField("X-Jenkins-CLI-Port");
if (p1==null) p1 = head.getHeaderField("X-Hudson-CLI-Port"); // backward compatibility
String p2 = head.getHeaderField("X-Jenkins-CLI2-Port");
String identity = head.getHeaderField("X-Instance-Identity");
flushURLConnection(head);
if (p1==null && p2==null) {
verifyJenkinsConnection(head);
throw new IOException("No X-Jenkins-CLI2-Port among " + head.getHeaderFields().keySet());
}
if (p2!=null) return new CliPort(new InetSocketAddress(h,Integer.parseInt(p2)),identity,2);
else return new CliPort(new InetSocketAddress(h,Integer.parseInt(p1)),identity,1);
}
代码示例来源:origin: scouter-project/scouter
/**
* Returns the URL.
*
* @return null if the class file could not be obtained.
*/
public URL find(String classname) {
try {
URLConnection con = openClassfile0(classname);
InputStream is = con.getInputStream();
if (is != null) {
is.close();
return con.getURL();
}
}
catch (IOException e) {}
return null;
}
代码示例来源:origin: org.javassist/javassist
/**
* Returns the URL.
*
* @return null if the class file could not be obtained.
*/
@Override
public URL find(String classname) {
try {
URLConnection con = openClassfile0(classname);
InputStream is = con.getInputStream();
if (is != null) {
is.close();
return con.getURL();
}
}
catch (IOException e) {}
return null;
}
代码示例来源:origin: scouter-project/scouter
/**
* Returns the URL.
*
* @return null if the class file could not be obtained.
*/
@Override
public URL find(String classname) {
try {
URLConnection con = openClassfile0(classname);
InputStream is = con.getInputStream();
if (is != null) {
is.close();
return con.getURL();
}
}
catch (IOException e) {}
return null;
}
代码示例来源:origin: spotbugs/spotbugs
public InputStream progessMonitoredInputStream(URLConnection c, String msg) throws IOException {
InputStream in = c.getInputStream();
int length = c.getContentLength();
return wrapGzip(progressMonitoredInputStream(in, length, msg), c.getURL());
}
代码示例来源:origin: jenkinsci/jenkins
if (con != null && con.getURL() != null && !src.toString().equals(con.getURL().toString())) {
extraMessage = " (redirected to: " + con.getURL() + ")";
代码示例来源:origin: org.codehaus.groovy/groovy
public URL loadGroovySource(String className) throws MalformedURLException {
String filename;
for (String extension : getConfig().getScriptExtensions()) {
filename = className.replace('.', File.separatorChar) + "." + extension;
try {
URLConnection dependentScriptConn = rc.getResourceConnection(filename);
return dependentScriptConn.getURL();
} catch (ResourceException e) {
//TODO: maybe do something here?
}
}
return rl.loadGroovySource(className);
}
});
代码示例来源:origin: org.codehaus.groovy/groovy
/**
* Get the class of the scriptName in question, so that you can instantiate
* Groovy objects with caching and reloading.
*
* @param scriptName resource name pointing to the script
* @return the loaded scriptName as a compiled class
* @throws ResourceException if there is a problem accessing the script
* @throws ScriptException if there is a problem parsing the script
*/
public Class loadScriptByName(String scriptName) throws ResourceException, ScriptException {
URLConnection conn = rc.getResourceConnection(scriptName);
String path = conn.getURL().toExternalForm();
ScriptCacheEntry entry = scriptCache.get(path);
Class clazz = null;
if (entry != null) clazz = entry.scriptClass;
try {
if (isSourceNewer(entry)) {
try {
String encoding = conn.getContentEncoding() != null ? conn.getContentEncoding() : config.getSourceEncoding();
String content = IOGroovyMethods.getText(conn.getInputStream(), encoding);
clazz = groovyLoader.parseClass(content, path);
} catch (IOException e) {
throw new ResourceException(e);
}
}
} finally {
forceClose(conn);
}
return clazz;
}
代码示例来源:origin: org.codehaus.groovy/groovy
String finalName = name + "." + ext;
URLConnection conn = rc.getResourceConnection(finalName);
URL url = conn.getURL();
String path = url.toExternalForm();
ScriptCacheEntry entry = scriptCache.get(path);
代码示例来源:origin: org.codehaus.groovy/groovy
try {
cache.get(depSourcePath);
cu.addSource(getResourceConnection(depSourcePath).getURL());
} catch (ResourceException e) {
代码示例来源:origin: stackoverflow.com
URLConnection con = new URL(url).openConnection();
System.out.println("Orignal URL: " + con.getURL());
con.connect();
System.out.println("Connected URL: " + con.getURL());
InputStream is = con.getInputStream();
System.out.println("Redirected URL: " + con.getURL());
is.close();
代码示例来源:origin: stackoverflow.com
String getShareURL(String strURL) {
URLConnection conn = null;
String redirectedUrl = null;
try {
URL inputURL = new URL(strURL);
conn = inputURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
System.out.println("Redirected URL: " + conn.getURL());
redirectedUrl = conn.getURL().toString();
is.close();
} catch (MalformedURLException e) {
Log.d(TAG, "Please input a valid URL");
} catch (IOException ioe) {
Log.d(TAG, "Can not connect to the URL");
}
return redirectedUrl;
}
代码示例来源:origin: magefree/mage
try (InputStream inputStream = conn.getURL().openStream()) {
List<TokenData> siteTokensData = parseTokensData(inputStream);
for (TokenData siteData : siteTokensData) {
代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib
/**
* Convenience method to make it easier to verify connections
*
* @param connection The connection to match
* @return true if this connection should be handled.
*/
protected boolean matches(URLConnection connection) {
return matches(connection.getURL());
}
代码示例来源:origin: rometools/rome
/**
* @param eventType The event type to fire
* @param connection the current connection
*/
protected void fireEvent(final String eventType, final URLConnection connection) {
fireEvent(eventType, connection.getURL().toExternalForm(), null);
}
内容来源于网络,如有侵权,请联系作者删除!