Java Spring和Hibernate简单配置

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
          lazy-init="true" parent="classesListContainer">
        <property name="dataSource">
            <ref bean="dataSource"/>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.SybaseDialect</prop>
                <!--<prop key="hibernate.show_sql">true</prop>-->
                <!--<prop key="hibernate.format_sql">true</prop>-->
                <!--<prop key="hibernate.hbm2ddl.auto">validate</prop>-->
            </props>
        </property>
        <property name="annotatedClasses">
            <list>
                <value>com.dummy.DummyClass</value>
                <!-- list of all the annotated classes -->                 
            </list>
        </property>
</bean>

<!-- A template which works with hbm -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate" lazy-init="true">
        <property name="sessionFactory" ref="sessionFactory"/>
</bean>

Java 使用Java阅读网页

public String readURL(String address) throws Exception
{
    URL url = new URL(address);
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setReadTimeout(5000);
    conn.setConnectTimeout(5000);

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    byte[] buff = new byte[1024];
    InputStream in = conn.getInputStream();
    int read;

    while((read = in.read(buff)) != -1)
        out.write(buff, 0, read);

    return out.toString().replaceAll("[\\s]+", " ");
}

Java 读取属性文件

Properties properties = new Properties(); 
try 
{ 
    properties.load(new FileInputStream("filename.properties")); 
} 
catch (IOException e) 
{ 
    // implement catch logic
}