如何通过sun.net.www.protocol.jar.JarURLConnection $ JarURLInputStream实例获取字节数组?

时间:2015-07-20 15:47:20

标签: java spring

我正在使用DefaultPropertiesPersister来覆盖属性。我的配置是这样的。

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
    <property name="locations">
      <list>
          <value>classpath:/META-INF/properties/common.properties</value>
          <value>classpath:/META-INF/properties/${spring.profiles.active}.properties</value>
          <value>classpath:/META-INF/properties/${spring.profiles.active}.passwords</value>
          <value>classpath:/META-INF/properties/local.properties</value>
      </list>
    </property>
    <property name="propertiesPersister">
        <bean class="com.freecharge.ums.server.service.MyPropertyPersister" />
    </property>        
</bean>

现在,在扩展DefaultPropertiesPersister之后,我重写了方法:

load(Properties props, InputStream is)

现在启动jar之后,我得到的InputStream属于sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream类型。当我尝试使用byte[]将其转换为IOUtils.toByteArray(is)时,我什么都没得到。

当我通过main方法运行相同的东西时,我通过,因为我得到的流是java.io.BufferedInputStream,它能够将其转换为字节数组。

进行了大量的研究,但无法完成这项工作。提前谢谢。

<{1}}类中的

加载方法实现如下:

MyPropertyPersister

0 个答案:

没有答案