当前位置: 首页>>代码示例>>Java>>正文


Java URLConnection.getURL方法代码示例

本文整理汇总了Java中java.net.URLConnection.getURL方法的典型用法代码示例。如果您正苦于以下问题:Java URLConnection.getURL方法的具体用法?Java URLConnection.getURL怎么用?Java URLConnection.getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.net.URLConnection的用法示例。


在下文中一共展示了URLConnection.getURL方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkHttpConnection

import java.net.URLConnection; //导入方法依赖的package包/类
public static void checkHttpConnection(URLConnection urlConnection) {
    URL url = null;
    try {
        if (urlConnection != null) {
            url = urlConnection.getURL();

        }
    } catch (Exception e) {
        HookHandler.LOGGER.warn(e.getMessage());
    }
    if (url != null) {
        checkHttpUrl(url.toString(), urlConnection.getURL().getHost(), "url_open_connection");
    }
}
 
开发者ID:baidu,项目名称:openrasp,代码行数:15,代码来源:URLConnectionHook.java

示例2: initPumping

import java.net.URLConnection; //导入方法依赖的package包/类
private void initPumping(URLConnection connection) throws IOException {
    final Date lastModif = new Date(connection.getLastModified());
    final URL realUrl = connection.getURL();
    final String accept = connection.getHeaderField("Accept-Ranges");
    final boolean acceptBytes = accept != null ? accept.contains("bytes"): false;
    final long length = connection.getContentLength();
    pumping.init(realUrl, length, lastModif, acceptBytes);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Pump.java

示例3: getContent

import java.net.URLConnection; //导入方法依赖的package包/类
/**
 * Returns one of several object types (this set may change in future
 * versions):
 * 1) instance of Thread:
 *    Invoke the thread to launch an external viewer.
 * 2) instance of InputStream:
 *    Bring up the "Save to disk" dialog page to allow the content
 *    to be saved to disk.
 * 3) instance of InputStreamImageSource:
 *    Load the image into HotJava in an image viewer page.
 * 4) instance of String:
 *    Go to a new page with the string as the plain text content
 *    of that page.
 */
public Object getContent(URLConnection uc) {
    try {
        InputStream is = uc.getInputStream();
        StringBuffer sb = new StringBuffer();
        int c;

        sb.append("[Content of " + uc.getURL() + "]\n\n");
        sb.append("[This opening message brought to you by your plain/text\n");
        sb.append("content handler. To remove this content handler, delete the\n");
        sb.append("COM.foo.content.text directory from your class path and\n");
        sb.append("the java.content.handler.pkgs property from your HotJava\n");
        sb.append("properties file.]\n");
        sb.append("----------------------------------------------------------------\n\n");

        // Read the characters from the source, accumulate them into the string buffer.
        // (Not the most efficient, but simplest for this example.)
        while ((c = is.read()) >= 0) {
            sb.append((char)c);
        }

        // Tidy up
        is.close();

        // Return the resulting string to our client (we're case 4 above)
        return sb.toString();
    } catch (IOException e) {
        // For any exception, just return an indication of what went wrong.
        return "Problem reading document: " + uc.getURL();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:plain.java

示例4: getJSFileFromURL

import java.net.URLConnection; //导入方法依赖的package包/类
private String getJSFileFromURL(URLConnection paramURLConnection)
		throws Exception {
	// Trace.msgNetPrintln("net.proxy.auto.download.js", new Object[] {
	// paramURLConnection.getURL() });
	try {
		// RemoveCommentReader localRemoveCommentReader = new
		// RemoveCommentReader(new
		// InputStreamReader(paramURLConnection.getInputStream()));
		InputStreamReader localRemoveCommentReader = new InputStreamReader(
				paramURLConnection.getInputStream());
		BufferedReader localBufferedReader = new BufferedReader(
				localRemoveCommentReader);
		StringWriter localStringWriter = new StringWriter();
		char[] arrayOfChar = new char[100];
		int i;
		while ((i = localBufferedReader.read(arrayOfChar)) != -1) {
			localStringWriter.write(arrayOfChar, 0, i);
		}
		localBufferedReader.close();
		localRemoveCommentReader.close();
		localStringWriter.close();
		return localStringWriter.toString();
	} catch (Throwable localThrowable) {
		throw new Exception("Unable to obtain auto proxy file from "
				+ paramURLConnection.getURL(), localThrowable);
	}
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:28,代码来源:AbstractAutoProxyHandler.java

示例5: getInputStreamOfURL

import java.net.URLConnection; //导入方法依赖的package包/类
public InputStream getInputStreamOfURL(URL downloadURL, Proxy proxy) throws IOException{
    
    URLConnection ucn = null;
    
    // loop until no more redirections are 
    for (;;) {
        if (Thread.currentThread().isInterrupted()) {
            return null;
        }
        if(proxy != null) {
            ucn = downloadURL.openConnection(proxy);
        } else {
            ucn = downloadURL.openConnection();
        }
        HttpURLConnection hucn = doConfigureURLConnection(ucn);

        if(Thread.currentThread().isInterrupted())
            return null;
    
        ucn.connect();

        int rc = hucn.getResponseCode();
        boolean isRedirect = 
                rc == HttpURLConnection.HTTP_MOVED_TEMP ||
                rc == HttpURLConnection.HTTP_MOVED_PERM;
        if (!isRedirect) {
            break;
        }

        String addr = hucn.getHeaderField(HTTP_REDIRECT_LOCATION);
        URL newURL = new URL(addr);
        if (!downloadURL.getProtocol().equalsIgnoreCase(newURL.getProtocol())) {
            throw new ResourceRedirectException(newURL);
        }
        downloadURL = newURL;
    }

    ucn.setReadTimeout(10000);
    InputStream is = ucn.getInputStream();
    streamLength = ucn.getContentLength();
    effectiveURL = ucn.getURL();
    return is;
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:URLResourceRetriever.java

示例6: URLImageSource

import java.net.URLConnection; //导入方法依赖的package包/类
public URLImageSource(URLConnection uc) {
    this(uc.getURL(), uc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:URLImageSource.java

示例7: newResponse

import java.net.URLConnection; //导入方法依赖的package包/类
/**
 * Returns a web response built from a URL connection. Provided to allow
 * access to WebResponse parsing without using a WebClient.
 **/
public static WebResponse newResponse( URLConnection connection ) throws IOException {
    return new HttpWebResponse( null, FrameSelector.TOP_FRAME, connection.getURL(), connection, HttpUnitOptions.getExceptionsThrownOnErrorStatus() );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:WebResponse.java

示例8: newResponse

import java.net.URLConnection; //导入方法依赖的package包/类
/**
 * Returns a web response built from a URL connection. Provided to allow
 * access to WebResponse parsing without using a WebClient.
 **/
public static WebResponse newResponse( URLConnection connection ) throws IOException {
    return new HttpWebResponse( null, "_top", connection.getURL(), connection, HttpUnitOptions.getExceptionsThrownOnErrorStatus() );
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:8,代码来源:WebResponse.java


注:本文中的java.net.URLConnection.getURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。