本文整理汇总了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);
}
示例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);
}
}
示例3: toUri
import java.net.URL; //导入方法依赖的package包/类
private static URI toUri(URL url) {
try {
return url.toURI();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
示例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);
}
示例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();
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}