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


Java URL.setURLStreamHandlerFactory方法代码示例

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


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

示例1: testTheCopyProblem

import java.net.URL; //导入方法依赖的package包/类
public void testTheCopyProblem() throws Exception {
    clearWorkDir();
    
    URL.setURLStreamHandlerFactory(new ProxyURLStreamHandlerFactory());

    File tempFileSource = new File(getWorkDir(), "source");
    tempFileSource.mkdirs();
    File tempFile1 = File.createTempFile("test.test1", "", tempFileSource);
    tempFile1.delete();
    tempFile1.mkdir();
    File tempFile2 = File.createTempFile("test.test2", "", tempFileSource);
    tempFile2.delete();
    tempFile2.mkdir();

    File tempFileTarget = new File(getWorkDir(), "target");
    tempFileTarget.mkdir();

    FileObject sourceFo = FileUtil.toFileObject(tempFileSource);
    FileObject targetFo = FileUtil.toFileObject(tempFileTarget);

    FileUtil.copyFile(sourceFo, targetFo, "source");       

    assertNotNull(targetFo.getFileObject("source/" + tempFile1.getName()));
    assertNotNull(targetFo.getFileObject("source/" + tempFile2.getName()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FolderCopyProblemTest.java

示例2: initHttpURLConnection

import java.net.URL; //导入方法依赖的package包/类
private static void initHttpURLConnection(Context context) {
    CronetEngine.Builder myBuilder = new CronetEngine.Builder(context);
    myBuilder.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 100 * 1024)
            .enableHttp2(true)
            .enableQuic(true)
            .enableSDCH(true)
            .setHostResolver(new HostResolver() {
                @Override
                public List<InetAddress> resolve(String hostname) throws UnknownHostException {
                    if (hostname == null)
                        throw new UnknownHostException("hostname == null");
                    return Arrays.asList(InetAddress.getAllByName(hostname));
                }
            })
            .enableSDCH(true)
            .setLibraryName("cronet");
    CronetEngine cronetEngine = myBuilder.build();
    CronetURLStreamHandlerFactory cronetURLStreamHandlerFactory = new CronetURLStreamHandlerFactory(cronetEngine);
    URL.setURLStreamHandlerFactory(cronetURLStreamHandlerFactory);
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:21,代码来源:MainActivity.java

示例3: registerHandler

import java.net.URL; //导入方法依赖的package包/类
public static void registerHandler(final AssetManager manager) {
    URL.setURLStreamHandlerFactory(protocol -> "assets".equals(protocol) ? new URLStreamHandler() {
        protected URLConnection openConnection(URL url) throws IOException {
            return new URLConnection(url) {
                @Override
                public void connect() throws IOException {
                }

                @Override
                public InputStream getInputStream() throws IOException {
                    return manager.open(url.getFile());
                }
            };
        }
    } : null);
}
 
开发者ID:stariy95,项目名称:cayenne-android-demo,代码行数:17,代码来源:UrlToAssetUtils.java

示例4: installGitProtocol

import java.net.URL; //导入方法依赖的package包/类
/**
 * Installs the GIT protocol that we use to identify certain file versions.
 */
protected void installGitProtocol() {
  // Install protocol.
  try {
  URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
    @Override
    public URLStreamHandler createURLStreamHandler(String protocol) {
      if (protocol.equals(GitRevisionURLHandler.GIT_PROTOCOL)) {
        URLStreamHandler handler = new GitRevisionURLHandler();
        return handler;
      }
      
      return null;
    }
  });
  } catch (Throwable t) {
    if (!t.getMessage().contains("factory already defined")) {
      logger.info(t, t);
    }
  } 
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:24,代码来源:GitTestBase.java

示例5: testInitializationWithRegisteredStreamFactory

import java.net.URL; //导入方法依赖的package包/类
/**
 * Check if FileSystem can be properly initialized if URLStreamHandlerFactory
 * is registered.
 */
@Test
public void testInitializationWithRegisteredStreamFactory() {
  Configuration conf = new Configuration();
  URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory(conf));
  try {
    FileSystem.getFileSystemClass("file", conf);
  }
  catch (IOException ok) {
    // we might get an exception but this not related to infinite loop problem
    assertFalse(false);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:17,代码来源:TestFileSystemInitialization.java

示例6: setupApiLayer

import java.net.URL; //导入方法依赖的package包/类
private static void setupApiLayer() {
	try {
		URL.setURLStreamHandlerFactory(new Util.MatrixMediaURLStreamHandlerFactory());
	} catch (Error e) {
		return; // Operation only permitted once; catching for harness.
	}
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:8,代码来源:SdkFactory.java

示例7: update

import java.net.URL; //导入方法依赖的package包/类
@Test
public void update() throws RestfulHTTPException, IOException {
	// Required to make URL class accept mxc:// protocol
	URL.setURLStreamHandlerFactory(new Util.MatrixMediaURLStreamHandlerFactory());

	user.update();
	Assert.assertEquals(
		"User object did not parse display name",
		user.getName(),
		"Morpheus"
	);
}
 
开发者ID:Gurgy,项目名称:Cypher,代码行数:13,代码来源:UserTest.java

示例8: setup

import java.net.URL; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
    URL.setURLStreamHandlerFactory(
            DirContextURLStreamHandlerFactory.getInstance());
    File buildDir = new File(
            System.getProperty("tomcat.test.tomcatbuild", "output/build"));
    System.setProperty("catalina.base", buildDir.getAbsolutePath());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:9,代码来源:TestConfigFileLoader.java

示例9: IDEInitializer

import java.net.URL; //导入方法依赖的package包/类
public IDEInitializer () {
    Assert.assertNull (DEFAULT_LOOKUP);
    DEFAULT_LOOKUP = this;
    URL.setURLStreamHandlerFactory (new MyURLHandlerFactory ());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:IDEInitializer.java

示例10: setUp

import java.net.URL; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    this.clearWorkDir();
    try {
        URL.setURLStreamHandlerFactory(new ProxyURLStreamHandlerFactory());
    } catch (Error ex) {
        // nop 
    }
    final File _wd = this.getWorkDir();
    final FileObject wd = FileUtil.toFileObject(_wd);

    assertNotNull("No masterfs",wd);
    srcRoot1 = wd.createFolder("src1");
    assertNotNull(srcRoot1);
    srcRoot2 = wd.createFolder("src2");
    assertNotNull(srcRoot2);
    srcRoot3 = wd.createFolder("src3");
    assertNotNull (srcRoot3);
    compRoot1 = wd.createFolder("comp1");
    assertNotNull (compRoot1);
    compRoot2 = wd.createFolder("comp2");
    assertNotNull (compRoot2);
    bootRoot1 = wd.createFolder("boot1");
    assertNotNull (bootRoot1);
    bootRoot2 = wd.createFolder("boot2");
    assertNotNull (bootRoot2);
    compSrc1 = wd.createFolder("cs1");
    assertNotNull (compSrc1);
    compSrc2 = wd.createFolder("cs2");
    assertNotNull (compSrc2);
    bootSrc1 = wd.createFolder("bs1");
    assertNotNull (bootSrc1);
    unknown1 = wd.createFolder("uknw1");
    assertNotNull (unknown1);
    unknown2 = wd.createFolder("uknw2");
    assertNotNull (unknown2);
    unknownSrc2 = wd.createFolder("uknwSrc2");
    assertNotNull(unknownSrc2);
    SFBQImpl.register (bootRoot1,bootSrc1);
    SFBQImpl.register (compRoot1,compSrc1);
    SFBQImpl.register (compRoot2,compSrc2);
    SFBQImpl.register (unknown2,unknownSrc2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:PathRegistryTest.java

示例11: IDEInitializer

import java.net.URL; //导入方法依赖的package包/类
public IDEInitializer() {
    Assert.assertNull(DEFAULT_LOOKUP);
    DEFAULT_LOOKUP = this;
    URL.setURLStreamHandlerFactory(new MyURLHandlerFactory());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:NotificationCategoryFactoryTest.java

示例12: setup

import java.net.URL; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
    URL.setURLStreamHandlerFactory(DirContextURLStreamHandlerFactory.getInstance());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:TestClasspathUrlStreamHandler.java


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