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


Java URL.hashCode方法代码示例

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


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

示例1: testURLNoInetAccess

import java.net.URL; //导入方法依赖的package包/类
public void testURLNoInetAccess() throws MalformedURLException, IOException {
    URL url1 = new URL ("nbinst://test-module/modules/test.txt");   // NOI18N
    URL url2 = new URL ("nbinst://foo-module/modules/test.txt");    // NOI18N
    SecurityManager defaultManager = System.getSecurityManager();
    
    System.setSecurityManager(new InetSecurityManager());
    try {
        // make sure we do not try to resolve host name
        url1.hashCode();
        url1.equals(url2);
        testURLConnection();
    } finally {
        System.setSecurityManager(defaultManager);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:NbinstURLMapperTest.java

示例2: getTempFileName

import java.net.URL; //导入方法依赖的package包/类
protected String getTempFileName(URL url, String template) {
    String tempFilename = template;

    // Replace all but last occurrance of "%s" with timestamp to insure
    // uniqueness.  There's a subtle behavior here: if there is anything
    // _after_ the last "%s" we need to append it so that unusual launch
    // strings that have the datafile in the middle can still be used.
    int wildcard = tempFilename.lastIndexOf("%s");
    String prefix = tempFilename.substring(0, wildcard);

    String suffix = "";
    if (wildcard < tempFilename.length() - 2) {
        suffix = tempFilename.substring(wildcard + 2);
    }

    long timestamp = System.currentTimeMillis()/1000;
    int argIndex = 0;
    while ((argIndex = prefix.indexOf("%s")) >= 0) {
        prefix = prefix.substring(0, argIndex)
            + timestamp
            + prefix.substring(argIndex + 2);
    }

    // Add a file name and file-extension if known
    String filename = url.getFile();

    String extension = "";
    int dot = filename.lastIndexOf('.');

    // BugId 4084826:  Temp MIME file names not always valid.
    // Fix:  don't allow slashes in the file name or extension.
    if (dot >= 0 && dot > filename.lastIndexOf('/')) {
        extension = filename.substring(dot);
    }

    filename = "HJ" + url.hashCode();

    tempFilename = prefix + filename + timestamp + extension + suffix;

    return tempFilename;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:MimeLauncher.java


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