當前位置: 首頁>>代碼示例>>Java>>正文


Java URL.toExternalForm方法代碼示例

本文整理匯總了Java中java.net.URL.toExternalForm方法的典型用法代碼示例。如果您正苦於以下問題:Java URL.toExternalForm方法的具體用法?Java URL.toExternalForm怎麽用?Java URL.toExternalForm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.URL的用法示例。


在下文中一共展示了URL.toExternalForm方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readTableEntry

import java.net.URL; //導入方法依賴的package包/類
/**
 * @param aFileUrl
 * @param aTables
 * @throws IOException
 * @throws NotSupportedException
 */
protected static void readTableEntry(URL aFileUrl, ArrayList aTables) 
	throws IOException, NotSupportedException
{
 Logger.println("JGRIB: readTableEntry: aFileUrl = "+aFileUrl.toString(), Logger.DEBUG);
 InputStreamReader isr = new InputStreamReader(aFileUrl.openStream());
 BufferedReader br = new BufferedReader(isr);

    String line = br.readLine();
    if (line.length() == 0 || line.startsWith("//")) {
 	   throw new NotSupportedException("Gribtab files cannot start with blanks " +
     			"or comments, - Please follow standard (-1:center:subcenter:tablenumber)");
 }
 GribPDSParamTable table = new GribPDSParamTable();
 String[] tableDefArr = SmartStringArray.split(":", line);
 table.center_id = Integer.parseInt(tableDefArr[1].trim());
 table.subcenter_id = Integer.parseInt(tableDefArr[2].trim());
 table.table_number = Integer.parseInt(tableDefArr[3].trim());
 table.filename = aFileUrl.toExternalForm();
 table.url = aFileUrl;

    aTables.add(table);

    br.close();
 isr.close();   
}
 
開發者ID:spidru,項目名稱:JGribX,代碼行數:32,代碼來源:GribPDSParamTable.java

示例2: normalizeUrl

import java.net.URL; //導入方法依賴的package包/類
public static URL normalizeUrl(final URL url) throws MalformedURLException {
    String queryString = url.getQuery();
    if (null == queryString) {
        return url;
    }
    String original = url.toExternalForm();
    StringBuilder sb = new StringBuilder();
    String[] array = queryString.split("&");
    for (String str : array) {
        String[] pair = str.split("=");
        if (2 != pair.length) {
            throw new IllegalArgumentException("Parse failed: " + original);
        }
        try {
            sb.append(pair[0]).append("=");
            sb.append(URLEncoder.encode(pair[1], ENCODING));
            sb.append("&");
        } catch (UnsupportedEncodingException ex) {
            throw new IllegalArgumentException(ex);
        }
    }
    return new URL(original.replace(queryString, StringUtils.chop(sb
            .toString())));
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:25,代碼來源:URLUtils.java

示例3: afterPropertiesSet

import java.net.URL; //導入方法依賴的package包/類
@Override
public void afterPropertiesSet() throws Exception {
    final String propValue = System.getProperty(SYS_PROP_LOGIN_CONF);
    if (propValue != null) {
        logger.warn("found login config in system property, may overide : {}", propValue);
    }

    URL url = getClass().getResource(
            this.loginConf == null ? DEFAULT_LOGIN_CONFIG : this.loginConf);
    if (url != null) {
        this.loginConf = url.toExternalForm();
    }
    if (this.loginConf != null) {
        System.setProperty(SYS_PROP_LOGIN_CONF, this.loginConf);
    } else {
        url = getClass().getResource("/jcifs/http/login.conf");
        if (url != null) {
            System.setProperty(SYS_PROP_LOGIN_CONF, url.toExternalForm());
        }
    }
    logger.debug("configured login configuration path : {}", propValue);
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:23,代碼來源:JCIFSConfig.java

示例4: getSystemId

import java.net.URL; //導入方法依賴的package包/類
/**
     * Get InputSource system ID. Use ordered logic:
     * <ul>
     *  <li>use client's <code>setSystemId()</code>, or
     *  <li>try to derive it from <code>Document</code>
     *      <p>e.g. look at <code>Document.StreamDescriptionProperty</code> for
     *      {@link DataObject} and use URL of its primary file.
     * </ul>
     * @return entity system Id or <code>null</code>
     */
    public String getSystemId() {
        
        String system = super.getSystemId();
        
        // XML module specifics property, promote into this API
//        String system = (String) doc.getProperty(TextEditorSupport.PROP_DOCUMENT_URL);        
        
        if (system == null) {
            final FileObject fo = EditorDocumentUtils.getFileObject(doc);
            if (fo != null) {
                URL url = fo.toURL();
                system = url.toExternalForm();
            } else {
                LOG.info("XML:DocumentInputSource:No FileObject in stream description.");   //NOI18N
            }
        }
        return system;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:DocumentInputSource.java

示例5: getURL

import java.net.URL; //導入方法依賴的package包/類
public String getURL(JPDAClassType clazz, String stratum) {
    if (!(stratum == null || JSUtils.JS_STRATUM.equals(stratum)) ||
        !clazz.getName().startsWith(JSUtils.NASHORN_SCRIPT)) {
        return null;
    }
    Source source = Source.getSource(clazz);
    if (source == null) {
        return null;
    }
    URL url = source.getRuntimeURL();
    if (url == null) {
        url = source.getUrl();
    }
    if (url != null) {
        return url.toExternalForm();
    } else {
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:FirstSourceURLProvider.java

示例6: Picto

import java.net.URL; //導入方法依賴的package包/類
public Picto(String name) {

            this.rectangle = new Rectangle();

            String soundResourceName = "pictogrammes/sounds/" + name + ".m4a";
            URL soundSourceResource = getClass().getClassLoader().getResource(soundResourceName);
            if (soundSourceResource == null) {
                throw new RuntimeException("Resource not found : " + soundResourceName);
            }

            this.sound = new AudioClip(soundSourceResource.toExternalForm());

            String imageResourceName = "pictogrammes/images/" + name + ".jpg";
            URL imageResource = getClass().getClassLoader().getResource(imageResourceName);
            if (imageResource == null) {
                throw new RuntimeException("Resource not found : " + imageResourceName);
            }
            rectangle.setFill(new ImagePattern(new Image(imageResource.toExternalForm()), 0, 0, 1, 1, true));
        }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:20,代碼來源:Pictos.java

示例7: proxifyURL

import java.net.URL; //導入方法依賴的package包/類
@Override
public String
proxifyURL(
	String url )
{
	try{
		URL _url = new URL( url );

		InetSocketAddress pa = (InetSocketAddress)proxy.address();

		_url = UrlUtils.setHost( _url, pa.getAddress().getHostAddress());
		_url = UrlUtils.setPort( _url, pa.getPort());

		url = _url.toExternalForm();

		url += ( url.indexOf('?')==-1?"?":"&" ) + "_azpproxy=1";

		return( url );

	}catch( Throwable e ){

		Debug.out( "Failed to proxify URL: " + url, e );

		return( url );
	}
}
 
開發者ID:BiglySoftware,項目名稱:BiglyBT,代碼行數:27,代碼來源:AEPluginProxyHandler.java

示例8: parse

import java.net.URL; //導入方法依賴的package包/類
/**
 * Converts to InputSource and pass it.
 */    
protected TreeDocumentRoot parse(FileObject fo) throws IOException, TreeException{
    
    try {
        URL url = fo.getURL();
        InputSource in = new InputSource(url.toExternalForm());  //!!! we could try ti get encoding from MIME content type
        in.setByteStream(fo.getInputStream());
        return parse(in);
        
    } catch (IOException ex) {
        ErrorManager emgr = ErrorManager.getDefault();
        emgr.annotate(ex, Util.THIS.getString("MSG_can_not_create_URL"));
        emgr.notify(ex);
    }           
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ParsingSupport.java

示例9: emptyVfsDir

import java.net.URL; //導入方法依賴的package包/類
private static Dir emptyVfsDir(final URL url) {
    return new Dir() {
        @Override
        public String getPath() {
            return url.toExternalForm();
        }

        @Override
        public Iterable<File> getFiles() {
            return Collections.emptyList();
        }

        @Override
        public void close() {

        }
    };
}
 
開發者ID:YMCoding,項目名稱:kafka-0.11.0.0-src-with-comment,代碼行數:19,代碼來源:ReflectionsUtil.java

示例10: authenticate

import java.net.URL; //導入方法依賴的package包/類
@Override
public HandlerResult authenticate(final Credential credential) throws GeneralSecurityException {
    final HttpBasedServiceCredential httpCredential = (HttpBasedServiceCredential) credential;
    if (!httpCredential.getService().getProxyPolicy().isAllowedProxyCallbackUrl(httpCredential.getCallbackUrl())) {
        logger.warn("Proxy policy for service [{}] cannot authorize the requested callbackurl [{}]",
                httpCredential.getService(), httpCredential.getCallbackUrl());
        throw new FailedLoginException(httpCredential.getCallbackUrl() + " cannot be authorized");
    }

    logger.debug("Attempting to authenticate {}", httpCredential);
    final URL callbackUrl = httpCredential.getCallbackUrl();
    if (!this.httpClient.isValidEndPoint(callbackUrl)) {
        throw new FailedLoginException(callbackUrl.toExternalForm() + " sent an unacceptable response status code");
    }
    return new DefaultHandlerResult(this, httpCredential, this.principalFactory.createPrincipal(httpCredential.getId()));
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:17,代碼來源:HttpBasedServiceCredentialsAuthenticationHandler.java

示例11: setStub

import java.net.URL; //導入方法依賴的package包/類
private static void setStub(Applet applet, final ClassLoader loader,
        boolean serialized, String beanName) throws ClassNotFoundException {
    // Get path to the resource representing the applet.
    String pathName = beanName.replace('.', '/');
    final String resourceName = serialized ? pathName.concat(".ser") : pathName.concat(".class"); //$NON-NLS-1$ //$NON-NLS-2$
    URL objectUrl = AccessController
            .doPrivileged(new PrivilegedAction<URL>() {
                public URL run() {
                    if (loader == null) {
                        return ClassLoader.getSystemResource(resourceName);
                    }
                    return loader.getResource(resourceName);
                }
            });

    // If we can't get to the applet itself, the codebase and doc base are
    // left as null.
    if (objectUrl == null) {
        applet.setStub(getAppletStub(getStubAppletContext(applet),
                null, null));
        return;
    }

    // Try to decompose the resource URL to get to the doc/code URL
    String urlString = objectUrl.toExternalForm();

    // This is the URL of the directory that contains the applet.
    int codeURLlength = urlString.length() - resourceName.length();
    URL codeBase = safeURL(urlString.substring(0, codeURLlength));

    // URL of the document containing the applet.
    int docURLlength = urlString.lastIndexOf('/');
    URL docBase = safeURL(urlString.substring(0, docURLlength + 1));

    applet.setStub(getAppletStub(getStubAppletContext(applet),
            codeBase, docBase));
}
 
開發者ID:yippeesoft,項目名稱:NotifyTools,代碼行數:38,代碼來源:Beans.java

示例12: getAvailableArtifactVersions

import java.net.URL; //導入方法依賴的package包/類
public static Map<Version, String> getAvailableArtifactVersions(String groupId, String artifactId, Collection<URL> repositories) throws IOException {
    Map<Version, String> availableVersions = new TreeMap<>(Version.descendingOrderComparator());

    final String relativePathToArtifact = groupId.replace(".", "/") + "/" + artifactId.replace(".", "/");

    String artifactLocation;
    for (final URL repository : repositories) {
        artifactLocation = repository.toExternalForm() + "/" + relativePathToArtifact;

        HttpURLConnection artifactRootConnection = HttpConfigurable.getInstance().openHttpConnection(artifactLocation);
        String artifactRootPage = StreamUtil.readText(artifactRootConnection.getInputStream(), StandardCharsets.UTF_8);

        Matcher artifactVersionMatcher = ARTIFACT_ROOT_VERSION_PATTERN.matcher(artifactRootPage);

        while (artifactVersionMatcher.find()) {
            String matchedVersion = artifactVersionMatcher.group(1);

            Version parsedVersion = Version.parseString(matchedVersion);

            if (parsedVersion != Version.INVALID) {
                String versionUrl = repository.toExternalForm() + "/" + relativePathToArtifact + "/" + parsedVersion.toString();
                availableVersions.put(parsedVersion, versionUrl);
            }
        }

        artifactRootConnection.disconnect();

        if (! availableVersions.isEmpty()) {
            break;
        }
    }

    return availableVersions;
}
 
開發者ID:mistodev,項目名稱:processing-idea,代碼行數:35,代碼來源:DependencyUtils.java

示例13: convertURLsToURIs

import java.net.URL; //導入方法依賴的package包/類
/**
 * Converts a list of {@link URL}s into a list of {@link URI}s.
 * @param urls the list of {@link URL}s to be converted
 * @param conversionMode the Policy for handling content items which
 * cannot be converted into @{link URI}s
 * @return the list of {@link URI}s
 * @throws IllegalArgumentException for unconvertable entry in
 * {@link ConversionMode#FAIL}
 * @since 1.48
 */
@NonNull
public static List<URI> convertURLsToURIs(
        @NonNull final List<URL> urls,
        @NonNull final ConversionMode conversionMode) {
    List<URI> content = new ArrayList<>();
    for (URL url : urls) {
        try {
            final URI uri = new URI (url.toExternalForm());
            content.add(uri);
        } catch (URISyntaxException e) {
            switch (conversionMode) {
                case FAIL:
                    throw new IllegalArgumentException(url.toString());
                case WARN:
                    LOG.log(
                        Level.WARNING,
                        "Cannot convert URL: {0} to URI.",  //NOI18N
                        url);
                    break;
                case SKIP:
                    break;
                default:
                    throw new IllegalStateException(conversionMode.name());
            }
        }
    }
    return content;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:LibrariesSupport.java

示例14: gatherReferences

import java.net.URL; //導入方法依賴的package包/類
/**
 * Parses the resource to detect the referenced resources.
 *  
 * @return The referenced resources.
 *  
 * @throws ParserConfigurationException
 * @throws SAXException
 * @throws IOException
 */
private Set<ReferencedResource> gatherReferences()
    throws ParserConfigurationException, SAXException, IOException {
  
  URL toParse = URLUtil.correct(resource.getLocation());
  InputSource is = new InputSource(toParse.toExternalForm());
  XMLReader xmlReader = parserCreator.createXMLReader();
  SaxContentHandler handler = new SaxContentHandler(toParse);
  xmlReader.setContentHandler(handler);
  xmlReader.parse(is);

  return handler.getDitaMapHrefs(); 
}
 
開發者ID:oxygenxml,項目名稱:oxygen-dita-translation-package-builder,代碼行數:22,代碼來源:MapStructureResourceBuilder.java

示例15: handle

import java.net.URL; //導入方法依賴的package包/類
@Override
public String handle(final Credential credential, final TicketGrantingTicket proxyGrantingTicketId) {
    final HttpBasedServiceCredential serviceCredentials = (HttpBasedServiceCredential) credential;
    final String proxyIou = this.uniqueTicketIdGenerator.getNewTicketId(ProxyGrantingTicket.PROXY_GRANTING_TICKET_IOU_PREFIX);

    final URL callbackUrl = serviceCredentials.getCallbackUrl();
    final String serviceCredentialsAsString = callbackUrl.toExternalForm();
    final int bufferLength = serviceCredentialsAsString.length() + proxyIou.length()
            + proxyGrantingTicketId.getId().length() + BUFFER_LENGTH_ADDITIONAL_CHARGE;
    final StringBuilder stringBuffer = new StringBuilder(bufferLength);

    stringBuffer.append(serviceCredentialsAsString);

    if (callbackUrl.getQuery() != null) {
        stringBuffer.append('&');
    } else {
        stringBuffer.append('?');
    }

    stringBuffer.append(PARAMETER_PROXY_GRANTING_TICKET_IOU);
    stringBuffer.append('=');
    stringBuffer.append(proxyIou);
    stringBuffer.append('&');
    stringBuffer.append(PARAMETER_PROXY_GRANTING_TICKET_ID);
    stringBuffer.append('=');
    stringBuffer.append(proxyGrantingTicketId);

    if (this.httpClient.isValidEndPoint(stringBuffer.toString())) {
        logger.debug("Sent ProxyIou of {} for service: {}", proxyIou, serviceCredentials);
        return proxyIou;
    }

    logger.debug("Failed to send ProxyIou of {} for service: {}", proxyIou, serviceCredentials);
    return null;
}
 
開發者ID:yuweijun,項目名稱:cas-server-4.2.1,代碼行數:36,代碼來源:Cas20ProxyHandler.java


注:本文中的java.net.URL.toExternalForm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。