宏大建设集团有限公司网站人事怎么做招聘网站比对分析

diannao/2025/10/17 3:56:49/文章来源:
宏大建设集团有限公司网站,人事怎么做招聘网站比对分析,如何网站做镜像,自己做的网站 怎么放大文件转载自 对Java的URL类支持的协议进行扩展的方法JAVA默认提供了对file,ftp,gopher,http,https,jar,mailto,netdoc协议的支持。当我们要利用这些协议来创建应用时#xff0c;主要会涉及到如下几个类#xff1a;java.net.URL、java.net.URLConnection、InputStream。URL类默认…转载自   对Java的URL类支持的协议进行扩展的方法JAVA默认提供了对file,ftp,gopher,http,https,jar,mailto,netdoc协议的支持。当我们要利用这些协议来创建应用时主要会涉及到如下几个类java.net.URL、java.net.URLConnection、InputStream。URL类默认支持上述协议但是有时候我们想自定义协议怎么办呢?Java提供了三种方法可以支持这个扩展 1、URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)URLStreamHandlerFactory(java.net.URLStreamHandlerFactory)这是一个接口定义如下 package java.net; /** * This interface defines a factory for {code URL} stream * protocol handlers. * p * It is used by the {code URL} class to create a * {code URLStreamHandler} for a specific protocol. * * author Arthur van Hoff * see java.net.URL * see java.net.URLStreamHandler * since JDK1.0 */ public interface URLStreamHandlerFactory { /** * Creates a new {code URLStreamHandler} instance with the specified * protocol. * * param protocol the protocol ({code ftp}, * {code http}, {code nntp}, etc.). * return a {code URLStreamHandler} for the specific protocol. * see java.net.URLStreamHandler */ URLStreamHandler createURLStreamHandler(String protocol); } 此接口需要实现createURLStreamHandler(String protocol)方法参数protocol为协议名称返回URLStreamHandler( java.net.URLStreamHandler )抽象类抽象方法定义如下 abstract protected URLConnection openConnection(URL u) throws IOException; 参数u为URL类型URL.openConnection间接调用这个方法返回URLConnection然后可以获取InputStream进而获取相应的数据(资源) 示例如下URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() { Override public URLStreamHandler createURLStreamHandler(String protocol) { if(json.equals(protocol)){ return new URLStreamHandler(){ Override protected URLConnection openConnection(URL url) throws IOException { return new URLConnection(url){ public InputStream getInputStream() throws IOException { return new FileInputStream(d:/aaaa.txt); } Override public void connect() throws IOException { //建立连接 } }; } }; } else return null; } }); URL url new URL(json://json.url.com); InputStream in url.openConnection().getInputStream(); System.out.println(in.read()); 上述代码判断如果协议(protocal)为json则返回一个自定义的URLStreamHandler否则返回null对应其他Java本身已经支持的协议会不会造成影响呢 我们且看URL的一个构造方法(URL(String protocol, String host, int port, String file,URLStreamHandler handler) 中类似) public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException { String original spec; int i, limit, c; int start 0; String newProtocol null; boolean aReffalse; boolean isRelative false; // Check for permission to specify a handler if (handler ! null) { SecurityManager sm System.getSecurityManager(); if (sm ! null) { checkSpecifyHandler(sm); } } try { limit spec.length(); while ((limit 0) (spec.charAt(limit - 1) )) { limit--; //eliminate trailing whitespace } while ((start limit) (spec.charAt(start) )) { start; // eliminate leading whitespace } if (spec.regionMatches(true, start, url:, 0, 4)) { start 4; } if (start spec.length() spec.charAt(start) #) { /* were assuming this is a ref relative to the context URL. * This means protocols cannot start w/ #, but we must parse * ref URLs like: hello:there w/ a : in them. */ aReftrue; } for (i start ; !aRef (i limit) ((c spec.charAt(i)) ! /) ; i) { if (c :) { String s spec.substring(start, i).toLowerCase(); if (isValidProtocol(s)) { newProtocol s; start i 1; } break; } } // Only use our context if the protocols match. protocol newProtocol; if ((context ! null) ((newProtocol null) || newProtocol.equalsIgnoreCase(context.protocol))) { // inherit the protocol handler from the context // if not specified to the constructor if (handler null) { handler context.handler; } // If the context is a hierarchical URL scheme and the spec // contains a matching scheme then maintain backwards // compatibility and treat it as if the spec didnt contain // the scheme; see 5.2.3 of RFC2396 if (context.path ! null context.path.startsWith(/)) newProtocol null; if (newProtocol null) { protocol context.protocol; authority context.authority; userInfo context.userInfo; host context.host; port context.port; file context.file; path context.path; isRelative true; } } if (protocol null) { throw new MalformedURLException(no protocol: original); } // Get the protocol handler if not specified or the protocol // of the context could not be used if (handler null (handler getURLStreamHandler(protocol)) null) { throw new MalformedURLException(unknown protocol: protocol); } this.handler handler; i spec.indexOf(#, start); if (i 0) { ref spec.substring(i 1, limit); limit i; } /* * Handle special case inheritance of query and fragment * implied by RFC2396 section 5.2.2. */ if (isRelative start limit) { query context.query; if (ref null) { ref context.ref; } } handler.parseURL(this, spec, start, limit); } catch(MalformedURLException e) { throw e; } catch(Exception e) { MalformedURLException exception new MalformedURLException(e.getMessage()); exception.initCause(e); throw exception; } } 代码87行调用了getURLStreamHandler(protocol)此方法 static URLStreamHandler getURLStreamHandler(String protocol) { URLStreamHandler handler handlers.get(protocol); if (handler null) { boolean checkedWithFactory false; // Use the factory (if any) if (factory ! null) { handler factory.createURLStreamHandler(protocol); checkedWithFactory true; } // Try java protocol handler if (handler null) { String packagePrefixList null; packagePrefixList java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction( protocolPathProp,)); if (packagePrefixList ! ) { packagePrefixList |; } // REMIND: decide whether to allow the null class prefix // or not. packagePrefixList sun.net.www.protocol; StringTokenizer packagePrefixIter new StringTokenizer(packagePrefixList, |); while (handler null packagePrefixIter.hasMoreTokens()) { String packagePrefix packagePrefixIter.nextToken().trim(); try { String clsName packagePrefix . protocol .Handler; Class? cls null; try { cls Class.forName(clsName); } catch (ClassNotFoundException e) { ClassLoader cl ClassLoader.getSystemClassLoader(); if (cl ! null) { cls cl.loadClass(clsName); } } if (cls ! null) { handler (URLStreamHandler)cls.newInstance(); } } catch (Exception e) { // any number of exceptions can get thrown here } } } synchronized (streamHandlerLock) { URLStreamHandler handler2 null; // Check again with hashtable just in case another // thread created a handler since we last checked handler2 handlers.get(protocol); if (handler2 ! null) { return handler2; } // Check with factory if another thread set a // factory since our last check if (!checkedWithFactory factory ! null) { handler2 factory.createURLStreamHandler(protocol); } if (handler2 ! null) { // The handler from the factory must be given more // importance. Discard the default handler that // this thread created. handler handler2; } // Insert this handler into the hashtable if (handler ! null) { handlers.put(protocol, handler); } } } return handler; } 代码段 if (factory ! null) { handler factory.createURLStreamHandler(protocol);checkedWithFactory true;}这一段是从factory中获取相应协议的URLStreamHandler如果获取不到则从另一渠道获得(即不会对java已经支持的协议造成影响)就是我们讲的第2种方法 各个构造方法的调用关系代码如下 //#1 public URL(String spec) throws MalformedURLException { this(null, spec);//调用#2 URL(URL context, String spec) } //#2 public URL(URL context, String spec) throws MalformedURLException { this(context, spec, null);调用#6 URL(URL context, String spec, URLStreamHandler handler) } //#3 public URL(String protocol, String host, int port, String file) throws MalformedURLException { this(protocol, host, port, file, null);//调用#6 RL(String protocol, String host, int port, String file,URLStreamHandler handler) } //#4 public URL(String protocol, String host, String file) throws MalformedURLException { this(protocol, host, -1, file);//调用#3 URL(String protocol, String host, int port, String file) } //#5 public URL(String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException{ //.... } //#6 public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException{ //.... } //可以看出实质性逻辑都在#5和#6方法 2、 通过 JVM 启动参数 -Djava.protocol.handler.pkgs来设置 URLStreamHandler 实现类的包路径 比如-D java.protocol.handler.pkgscom.myprotocol.pkgs0|com.myprotocol.pkgs1多个用|分割java默认的包为sun.net.www.protocol设置了这个参数会拼接在默认的包之后即sun.net.www.protocol|com.myprotocol.pkgs0|com.myprotocol.pkgs1 看这段代码 if (handler null) { String packagePrefixList null; packagePrefixList java.security.AccessController.doPrivileged( new sun.security.action.GetPropertyAction( protocolPathProp,));//protocolPathProp的值为java.protocol.handler.pkgs if (packagePrefixList ! ) { packagePrefixList |; } // REMIND: decide whether to allow the null class prefix // or not. packagePrefixList sun.net.www.protocol;//拼接默认的pkgs StringTokenizer packagePrefixIter new StringTokenizer(packagePrefixList, |); while (handler null packagePrefixIter.hasMoreTokens()) {//遍历pkgs String packagePrefix packagePrefixIter.nextToken().trim(); try { String clsName packagePrefix . protocol .Handler;//类全名为pkgs.protocal.Handler Class? cls null; try { cls Class.forName(clsName); } catch (ClassNotFoundException e) { ClassLoader cl ClassLoader.getSystemClassLoader(); if (cl ! null) { cls cl.loadClass(clsName); } } if (cls ! null) { handler (URLStreamHandler)cls.newInstance(); } } catch (Exception e) { // any number of exceptions can get thrown here } } } 类的命名模式为 [pkgs].[protocol].Handler比如默认实现” sun.net.www.protocol.[protocol].Handler”, 比如HTTP 协议的对应的处理类名为 -sun.net. www.protocol.http.Handler  自定义协议例子如下 package com.myprotocol.pkgs0.json; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; public class Handler extends URLStreamHandler { Override protected URLConnection openConnection(URL u) throws IOException { return new URLConnection(u) { public InputStream getInputStream() throws IOException { return new FileInputStream(d:/aaaa.txt); } Override public void connect() throws IOException { // 建立连接 } }; } } 启动时命令java -Djava.protocol.handler.pkgscom.myp rotocol.pkgs0 其他参数 主类3、构造方法URL((URL)null, json://www.google.com,new URLStreamHandler(){...}) 这种方法直接设置Handler比较简单,不在赘述代理Proxy URLStreamHandler 覆盖openConnection(URL) 和openConnection(URL,Proxy) 两个方法即可

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/92219.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

接单做网站wordpress后台管理插件

计算机内存原理 要说递归和栈的问题,首先就要说下计算机内存的基本原理。简单理解计算机内存原理可以将一台电脑看作超市的存包柜,每个柜子都有柜号(即计算机中的地址,如0x000000f)。当需要将数据存储到计算机中时&…

怎么在网上查网站空间是双线还是单线嘉兴网站建设方案策划

目录 ​​​​​​​一、文件和目录(II) 1、文件 2、目录 二、文件存取方法、存取控制(II) 1、文件存取方法 2、文件的访问 3、文件控制 三、常见嵌入式文件系统(I) 一、文件和目录(I…

可以做书的网站贷款网站建设

转载链接:http://www.jb51.net/css/72443.html 用css3的animation完成一个动画,当只有这个动画完成时才执行令一个事件,比如让动画保持在终止的状态或其他一些事件。我们该怎么办呢。 第一种方法: 用计时器,设定一个…

免费域名注册网站有哪些网站建设分享

下载Windows Live Writer整体安装包,最好是离线安装包 2.在xp系统上安装 3.查找C:\Program Files\Common Files\Windows Live\.cache目录 .cache目录是隐藏的,目录下面就是各个安装文件的msi安装包 4.拷贝相应的msi文件,到Windows 2003安装就…

茂名优化网站建设家装网站

前言 近日,艾伦人工智能研究所联合多个顶尖学术机构发布了史上首个100%开源的大模型“OLMo”,这一举措被认为是AI开源社区的一大里程碑。OLMo不仅公开了模型权重,还包括了完整的训练代码、数据集和训练过程,为后续的开源工作设立…

科技有限公司可以做网站建设吗媒体代发网站

文章目录 一、目标:容器事件和事件监听器二、设计:容器事件和事件监听器三、实现:容器事件和事件监听器3.1 工程结构3.2 容器事件和事件监听器类图3.3 定义和实现事件3.3.1 定义事件抽象类3.3.2 定义应用上下文事件实现类3.3.3 上下文刷新事件…

如何让网站上线中国最大的外贸平台

随着软件行业的飞速发展,互联网公司对开发者的技能要求也越来越高。而高并发、网络编程、微服务、海量数据的处理等技能,是每一个开发者进阶时的必学知识。为了帮助初级开发者快速掌握这些实用技术,本书以“理论+范例”的形式对各…

国内站长做国外网站php网站后台入口

获取源码资料,请移步从戎源码网:从戎源码网_专业的计算机毕业设计网站 项目介绍 基于springboot的学习英语管理系统:前端 thymeleaf、jquery,后端 maven、springmvc、spring、mybatis,角色分为管理员、用户&#xff…

设计单网站建设自己做视频网站如何接广告

基于Matlab的数据可视化 一、二维图形的绘制(一)基本图形函数(1)plot函数(2)fplot函数(3)其他坐标系的二维曲线 (二)图形属性设置(1)线…

网站集约化 建设方案电子商务网络营销的特点

使用 Spring Authorization Server 实现具有 PKCE 的单页应用程序进行身份验证 开启 CORS SPA 由静态资源组成,可以通过多种方式进行部署。它可以与后端分开部署,例如使用 CDN 或单独的 Web 服务器,也可以使用 Spring Boot 与后端一起部署。…

公司网站服务器租赁免费做ppt的网站

异地组网安装是指在不同地域的多个设备之间建立网络连接,以便实现数据传输和协同工作的过程。在如今的数字化时代,异地组网安装已经成为了许多企业和组织所必需的一项技术。 天联的使用场景 在异地组网安装中,天联是一种常用的工具。它具有以…

网站做seo收录wordpress 设置ftp

1、事务简介 事务(Transaction)是访问并可能更新数据库中各种数据项的一个程序执行单元(unit)。在关系数据库中,一个事务由一组SQL语句组成,事务具有4个属性:原子性、一致性、隔离性、持久性。这四个属性通常称为ACID原则。 原子性(atomici…

网站为什么被挂马长久新开传奇网站

distinct MongoDB 的 distinct 命令是获取特定字段中不同值列表的最简单工具。 该命令适用于普通字段、数组字段以及数组内嵌文档(集合对象)。 db.getCollection(customer).distinct("customer_type")// chances字段的值是个集合,获…

html5行业网站企业服务中心抖音

当构建高可用的网络应用时,负载均衡是至关重要的技术之一。Nginx 是一个强大的开源反向代理服务器,提供了丰富的负载均衡功能,包括负载均衡算法和健康检查。在本篇博客中,我们将讨论如何使用 Nginx 进行负载均衡,并结合…

门户网站推广优势小程序开发定制公司北京

一:题目 二:思路 1.这个题不能用优先队列,虽然我们可以通过优先队列得到最大值,但是我们在移动 窗口的时候,便不可以正常的删除元素了 2.虽然不能用优先对列,但是我们依然希望可以得到队首的元素的时候是最大值,同时还…

网站的下拉列表怎么做洛阳php网站开发

题目背景:目前往往需要对测序后的序列进行聚类与比对。其中聚类指的是将测序序列聚类以判断原始序列有多少条,聚类后相同类的序列定义为一个簇。比对则是指在聚类基础上对一个簇内的序列进行比对进而输出一条最有 可能的正确序列。通过聚类与比对将会极大…

建设网站主机可以用吗做软件开发有前途吗

Makefile中: ? 的区别 在Makefile中我们经常看到 : ? 这几个赋值运算符,那么他们有什么区别呢?我们来做个简单的实验 新建一个Makefile,内容为: ifdef DEFINE_VRE VRE “Hello World!” else endif ifeq ($(OPT),define) VRE…

工伤做实的那个网站找人做网站大概多少钱

有这样一个3位数,组成它的3个数字阶乘之和正好等于它本身。 即:abc a! b! c! 请找出所有满足要求的三位数.审好题很重要:三位数而非,三位数的个数 先写出一个函数求出某个数的阶乘,在跟别求出一个三位数的个十百位&…

178网站建设西安买公司的网站建设

今天在使用souce建表的时候发现自己表结构中的中文出现了乱码问题,那么具体的解决方案如下: 首先我们先使用命令行连接自己的数据库 mysql -u root -p 12345 然后使用show variables like "char%"; 如果说你的这个里面不是utf-8那么就是出现了…

php网站建设价格临沂制作网站软件

恕我直言,我一直都用 git pull 从来没有用过 git fetch git fetch, git pull 都可以用于获取远程仓库的内容,但它们有不同的作用和用法。 git fetch 用途:git fetch 用于从远程仓库获取最新的提交,但不会自动合并或更新本地分支…