易截截图软件、单文件、免安装、纯绿色、仅160KB

利用java Api解析XML

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
 * Usage: You can get a instance of Document from a string of xml.
 * This class supply some method to read a document.
 *
 */
public class XMLParser {
 /**
  * Get a instance of Document from a string of xml.
  *
  * @param xmlStr
  * @return Document
  */
 public static Document parse(String xmlStr) {
  if (xmlStr == null) {
   return null;
  }
  StringReader reader = new StringReader(xmlStr);
  InputSource source = new InputSource(reader);
  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  DocumentBuilder builder = null;
  try {
   builder = factory.newDocumentBuilder();
   
  } catch (ParserConfigurationException e) {
   e.printStackTrace();
  }
  if(builder == null){
   return null;
  }
  Document doc = null;
  try {
   doc = builder.parse(source);
  } catch (SAXException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  return doc;
 }
 
 /**
  * Get Item Value.
  * @param node
  * @return String
  */
 public static String getItemValue(Node node){
  String value = "";
  if(node == null){
   retur


相关文档:

JAVA JNI 使用实例

 JAVA可以通过JNI接口访问本地的动态连接库,从而扩展JAVA的功能。使用JAVA JNI接口主要包括以下步骤:
(1)编写JAVA代码,注明要访问的本地动态连接库和本地方法;
(2)编译JAVA代码得到.class文件;
(3)使用javah -jni 生成该类对应的C语言.h文件;
(4)使用C/C++实现(3)生成的.h文件中声明的各函数;
(5)编译C/ ......

Name java:comp is not bound in this Context

 
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
在tomcat中发布web项目,可能是因为spring中配置了jndi(只配置了jndi,其他的有工具包封装了)。
启动的时候报错(在项目目录下,在tomcat中配置context指向项目目录就没问题,打包发布到
tomcat就报错了),抛的异常是:
jav ......

1、怎样学习Java?

 1.了解Java的原理:
       首先要了解整个Java的大致结构、工作环境、历史。在这个过程中要搞明白Java从源代码到最后虚拟机里面执行的一个过程是怎样的。
2.学习Java语法:
      Java里面只有50多个关键字和一些运算符。语法结构就只有顺序、条件、循环 ......

Java事件机制

 事件源负责产生事件
事件类:定义事件的特征;
监听器接口:定义监听器应该实现的功能;
监听器:实现监听器接口,监听事件的发生并作出响应;
所有的事件类必须继承Java事件基类,即java.util.EventObject;EventObject(Object source)是EventObject唯一的构造方法,这意味着所有事件必须在实例化时就指定事件源 ......

java 事件机制探讨

java中的事件机制的参与者有3种角色:
1.event object:就是事件产生时具体的“事件”,用于listener的相应的方法之中,作为参数,一般存在与listerner的方法之中
2.event source:具体的接受事件的实体,比如说,你点击一个button,那么button就是event source,这样你必须使button对某些事件进行相应,你就需 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号