有些算法能想到或者也能看懂但是当自己去实现时去不能写出来了,求高手指点迷津。谢谢!
解决方案 »
- java.lang.NoSuchMethodError: com.sun.xml.bind.v2.runtime.JaxBeanInfo.getTypeName
- 一道算法题。
- 一个有趣的数组问题
- 安装JAVA SDK的问题。。
- 求教帮忙写个小系统
- 没人回答我的问题 5555555
- 下拉框联动的问题,急啊!
- 请问子类能不能重构父类的构造方法,如果能,怎么做?
- 怎样做tomcat4.03与iis集成?
- redhat7.1上用rpm装jdk1.3.0_01的rpm版,完成后设置/etc/profile,然后运行任何java程序,出现错误:装载libjvm.so出错,没有该文件,各路英雄块救命!
- 关于埃氏筛法求2到100之间的素数问题求解
- java 线程池 熟悉的进来看看 一段代码
{
public static void main(String[] args) throws IOException
{
Properties pro = new Properties();
FileInputStream fis = new FileInputStream("pro.properties");
pro.load(fis);
}}
import java.util.Map;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;public final class BeanFactory {
private static Map<String, Object> map = null;
private static String beanFile = "beanfactory.xml";
private static String beanFilePath = Thread.currentThread().getContextClassLoader().getResource(beanFile).getPath();
static {
load();
}
public static Object getBean(String beanName) {
return map.get(beanName);
}
private static void load() {
map = new HashMap<String, Object>();
try{
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(beanFilePath);
NodeList daos = doc.getElementsByTagName("beans");
int length = daos.getLength();
Element e = null;
for(int i=0; i<length; i++) {
e = (Element) daos.item(i);
map.put(e.getAttribute("name"), Class.forName(e.getAttribute("class")).newInstance());
}
e = null;
daos =null;
doc = null;
}catch(Exception e){
e.printStackTrace();
}
}
}
import java.util.Map;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;public final class BeanFactory {
private static Map<String, Object> map = null;
private static String beanFile = "beanfactory.xml";
private static String beanFilePath = Thread.currentThread().getContextClassLoader().getResource(beanFile).getPath();
static {
load();
}
public static Object getBean(String beanName) {
return map.get(beanName);
}
private static void load() {
map = new HashMap<String, Object>();
try{
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(beanFilePath);
NodeList daos = doc.getElementsByTagName("beans");
int length = daos.getLength();
Element e = null;
for(int i=0; i<length; i++) {
e = (Element) daos.item(i);
map.put(e.getAttribute("name"), Class.forName(e.getAttribute("class")).newInstance());
}
e = null;
daos =null;
doc = null;
}catch(Exception e){
e.printStackTrace();
}
}
}