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


Java URL.toURI方法代码示例

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


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

示例1: checkGeneration

import java.net.URL; //导入方法依赖的package包/类
private void checkGeneration(String name) throws URISyntaxException, IOException, JAXBException {
    URL testfileUrl = getClass().getResource(name + ".groovy");
    URL testfileResultUrl = getClass().getResource(name + ".xml");
    URL testfileResultUrlYaml = getClass().getResource(name + ".yaml");

    File file = new File(testfileUrl.toURI());
    File resultFile = new File(testfileResultUrl.toURI());
    File resultFileYaml = new File(testfileResultUrlYaml.toURI());


    Node updateScriptNode = XmlGenerator.getUpdateScriptNode(getInterpretingClass(file));
    StringWriter writer = new StringWriter();

    getMarshaller().marshal(updateScriptNode, writer);
    final String xml = writer.toString();
    final String yaml = getYamlString(YamlGenerator.getUpdateYamlScript(getInterpretingClass(file)));

    String expectedContent = FileUtils.fileRead(resultFile);
    String expectedContentYaml = FileUtils.fileRead(resultFileYaml);
    assertEquals("failed xml parsing of " + name, expectedContent, xml);
    assertEquals("failed yaml parsing of " + name, expectedContentYaml, yaml);

}
 
开发者ID:openweb-nl,项目名称:hippo-groovy-updater,代码行数:24,代码来源:TestUpdaterTransforming.java

示例2: validateURL

import java.net.URL; //导入方法依赖的package包/类
private void validateURL(final URL url, final File file) {
    try {
        final URI uri = url.toURI();
        if (!uri.isAbsolute()) {
            throw new IllegalArgumentException("URI is not absolute: " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
        if (uri.isOpaque()) {
            throw new IllegalArgumentException("URI is not hierarchical: " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
        if (!"file".equals(uri.getScheme())) {
            throw new IllegalArgumentException("URI scheme is not \"file\": " + uri.toString() + " File: " + file.getAbsolutePath());   //NOI18N
        }
    } catch (URISyntaxException use) {
        throw new IllegalArgumentException(use);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:J2SEModularProjectProperties.java

示例3: toUri

import java.net.URL; //导入方法依赖的package包/类
private static URI toUri(URL url) {
  try {
    return url.toURI();
  } catch (URISyntaxException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:spotify,项目名称:hype,代码行数:8,代码来源:ManifestLoaderTest.java

示例4: testJsonSchemaCacheSizeFromConfigFile

import java.net.URL; //导入方法依赖的package包/类
@Test
public void testJsonSchemaCacheSizeFromConfigFile() throws URISyntaxException, IOException {
    URL url = getClass().getResource("/connect-test.properties");
    File propFile = new File(url.toURI());
    String workerPropsFile = propFile.getAbsolutePath();
    Map<String, String> workerProps = !workerPropsFile.isEmpty() ?
            Utils.propsToStringMap(Utils.loadProps(workerPropsFile)) : Collections.<String, String>emptyMap();

    JsonConverter rc = new JsonConverter();
    rc.configure(workerProps, false);

}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:13,代码来源:JsonConverterTest.java

示例5: defaultBrokerXmlFileUri

import java.net.URL; //导入方法依赖的package包/类
private URI defaultBrokerXmlFileUri() throws Exception {
    String sourceOnClasspath =
            CoreConfigFactory.defaultBrokerXmlConfigLocation().toString();
    URL path = getClass().getClassLoader().getResource(sourceOnClasspath);
    // should be something like:
    // file:/your/path/to/omero-ms-queue/components/kew-artemis/build/resources/test/broker.xml

    assertNotNull(path);
    assertThat(path.getProtocol(), is("file"));

    return path.toURI();
}
 
开发者ID:openmicroscopy,项目名称:omero-ms-queue,代码行数:13,代码来源:CoreConfigFactoryTest.java

示例6: create

import java.net.URL; //导入方法依赖的package包/类
public static Template create(final URL url) {
    try {
        Template parameter = new Template();
        parameter.template = new File(url.toURI());
        return parameter;
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
开发者ID:jboz,项目名称:living-documentation,代码行数:10,代码来源:Template.java

示例7: testValidatePortTypeOperationDuplicateInputName

import java.net.URL; //导入方法依赖的package包/类
public void testValidatePortTypeOperationDuplicateInputName() throws Exception {
    String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/ptTests/opTests/ptMultiOpsDupInput_error.wsdl";
    URL url = getClass().getResource(fileName);
    URI uri = url.toURI();
    
    HashSet<String> expectedErrors = new HashSet<String>();
    expectedErrors.add(format(mMessages.getString("VAL_DUPLICATE_OPRATION_INPUT_NAME_IN_PORTTYPE")));
    validate(uri, expectedErrors);
    
            
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:WSDLSemanticValidatorTest.java

示例8: testInlineCrossReferenceValid

import java.net.URL; //导入方法依赖的package包/类
public void testInlineCrossReferenceValid() throws Exception {
      String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/typesTests/inlineSchemaTests/InlineSchemaCrossReference.wsdl";
    URL url = getClass().getResource(fileName);
    URI uri = url.toURI();
    
    validate(uri, 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WSDLInlineSchemaValidatorTest.java

示例9: testValidateMessageMultiName

import java.net.URL; //导入方法依赖的package包/类
public void testValidateMessageMultiName() throws Exception {
    String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/messageTests/messageMultiName_error.wsdl";
    URL url = getClass().getResource(fileName);
    URI uri = url.toURI();
    
    validate(uri, 1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WSDLSchemaValidatorTest.java

示例10: testValidateImportNoNamespace

import java.net.URL; //导入方法依赖的package包/类
public void testValidateImportNoNamespace() throws Exception {
    String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importNoNamespace_error.wsdl";
    URL url = getClass().getResource(fileName);
    URI uri = url.toURI();
    
    validate(uri, 2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WSDLSchemaValidatorTest.java

示例11: getSchemaFile

import java.net.URL; //导入方法依赖的package包/类
private File getSchemaFile(String resourceSchemaName) {
	URL schemaDir = this.getClass().getClassLoader().getResource(resourceSchemaName);
	try {
		return new File(schemaDir.toURI());
	} catch (URISyntaxException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:pegasystems,项目名称:api2swagger,代码行数:9,代码来源:TestSchemaGeneration.java

示例12: getContentsFromFileEntry

import java.net.URL; //导入方法依赖的package包/类
/***/
public static String getContentsFromFileEntry(final ZipEntry entry, String rootName) throws IOException,
URISyntaxException {
	URL rootURL = Thread.currentThread().getContextClassLoader().getResource(rootName);
	try (final ZipFile root = new ZipFile(new File(rootURL.toURI()));) {
		InputSupplier<InputStreamReader> readerSupplier = CharStreams.newReaderSupplier(
				new InputSupplier<InputStream>() {
					@Override
					public InputStream getInput() throws IOException {
						return root.getInputStream(entry);
					}
				}, Charsets.UTF_8);
		return CharStreams.toString(readerSupplier);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:TestCodeProvider.java

示例13: addBinary

import java.net.URL; //导入方法依赖的package包/类
@org.netbeans.api.annotations.common.SuppressWarnings(
value="DMI_COLLECTION_OF_URLS",
justification="URLs have never host part")
synchronized boolean addBinary(@NonNull final URL root) {
    if (binariesListener != null && !binaryRoots.containsKey(root)) {
        File f = null;
        final URL archiveUrl = FileUtil.getArchiveFile(root);
        try {
            final URI uri = archiveUrl != null ? archiveUrl.toURI() : root.toURI();
            if (uri.getScheme().equals("file")) { //NOI18N
                f = BaseUtilities.toFile(uri);
            }
        } catch (URISyntaxException use) {
            LOG.log (
                Level.INFO,
                "Can't convert: {0} to java.io.File, due to: {1}, (archive url: {2}).", //NOI18N
                new Object[]{
                    root,
                    use.getMessage(),
                    archiveUrl
                });
        }
        if (f != null) {
            if (archiveUrl != null) {
                // listening on an archive file
                safeAddFileChangeListener(binariesListener, f);
            } else {
                // listening on a folder
                safeAddRecursiveListener(binariesListener, f, null);
            }
            binaryRoots.put(root, Pair.of(f, archiveUrl != null));
        }
    }
    return listens;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:RootsListener.java

示例14: testValidateImportMultiNamespace

import java.net.URL; //导入方法依赖的package包/类
public void testValidateImportMultiNamespace() throws Exception {
    String fileName = "/org/netbeans/modules/xml/wsdl/validator/resources/importWSDLTests/importMultiNamespace_error.wsdl";
    URL url = getClass().getResource(fileName);
    URI uri = url.toURI();
    
    validate(uri, 1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:WSDLSchemaValidatorTest.java

示例15: findBinaryRoots

import java.net.URL; //导入方法依赖的package包/类
@Override
public BinaryForSourceQuery.Result findBinaryRoots(URL sourceRoot) {
    R res = null;
    try {
        final URI sourceRootURI = sourceRoot.toURI();
        res = cache.get(sourceRootURI);
        if (res == null) {
            res = createResult(sourceRoot, modules, binaryTemplates);
            if (res == null) {
                res = createResult(sourceRoot, testModules, testBinaryTemplates);
            }
            R prev = cache.get(sourceRootURI);
            if (prev != null) {
                res = prev;
            } else if (res != null) {
                prev = cache.putIfAbsent(sourceRootURI, res);
                if (prev != null) {
                    res = prev;
                }
            }
        }
    } catch (URISyntaxException e) {
        LOG.log(
                Level.WARNING,
                "Invalid URI: {0}", //NOI18N
                sourceRoot.toExternalForm());
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MultiModuleBinaryForSourceQueryImpl.java


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