java面试题2
18.做一个单子模式的类,只加载一次属性文件
package com.softeem.demo;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
/**
*@authorleno
*单子模式,保证在整个应用期间只加载一次配置属性文件
*/
publicclass Singleton {
privatestatic Singleton instance;
privatestaticfinal String CONFIG_FILE_PATH = "E:\\config.properties";
private Properties config;
private Singleton()
{
config = new Properties();
InputStream is;
try {
is = new FileInputStream(CONFIG_FILE_PATH);
config.load(is);
is.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
publicstatic Singleton getInstance()
{
if(instance==null)
{
instance = new Singleton();
}
returninstance;
}
public Properties getConfig() {
returnconfig;
}
publicvoid setConfig(Properties config) {
this.config = config;
}
}
l J2SE
19.拷贝一个目录(文件)到指定路径
/**
*拷贝一个目录或者文件到指定路径下
*@paramsource
*@pa
相关文档:
java(jsp)使用MySql数据库,中文乱码的完整解决方案
mysql是一个小型的开源的数据库,用来自学一些技术是十分方便的。但使用mysql存储数据,也会遇到一些非常恶心的问题,如:中文乱码问题、java驱动程序无法使用的问题(已经解决,详见:http://hi.baidu.com/lauo1988/blog/item/ff0da655bd3e2eceb745ae0b.html)。
......
本案例是使用SQLSERVER2005作为数据源,使用TOMCAT6.0
第一步,把以下代码拷贝到tomcat的安装目录conf文件夹context.xml文件下。
数据库连接请修改
<Resource name="jdbc/demo"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.microsoft.sqlserver.j ......
Sun公司一名员工自己创作的歌,关于Java EE 5,虽然不怎么好听,但歌词很有意思,程序员业余生活也可以这么丰富,羡慕!
Ladies and gentlemen, this is Java EE 5!
One, two, three, four, five
There’s a technology I use day and night
For my application with a web frontend
They told me to use .Net
......
1.现在输入n个数字,以逗号,分开;然后可选择升或者降序排序;按提交键就在另一页面显示按什么排序,结果为,提供reset
import java.util.*;
public class bycomma{
public static String[] splitStringByComma(String source){
if(source==null||source.trim().equals(""))
......