当前位置: 首页>>代码示例>>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;未经允许,请勿转载。