當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。