易截截图软件、单文件、免安装、纯绿色、仅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 找出100以内的素数

 public class FindPrime {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num = 100;
String s = "100以内的素数:";
for (int i = 1; i <= num; i++) {
int count = 0;
for (int j = 1; j <= (int) Math.s ......

java 找出4位数的所有吸血鬼数字

 /**
* 找出四位数所有的吸血鬼数字
* 吸血鬼数字:位数为偶数的数字可以由一对数字相乘而得,这对数字包含乘积一半的位数
* 如:1260 = 21*60
*/
public class Vampire {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

String s= ......

JAVA JNI 使用实例

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

Java学习笔记(2)体验云计算

  现在,谈云计算的可多了,不过,一般比较关注的是Google和Amazon的云服务。从大范围来看,也只有这两家获得了公众的更多关注。比如,我个人很感兴趣的,就是Google的App Engine使用户能够在Google基础设施上构建和托管 Web 应用程序。至于Amazon,它的AmazonWeb Services还包括Elastic Cloud Compute (EC2)计算Web服 ......

1、怎样学习Java?

 1.了解Java的原理:
       首先要了解整个Java的大致结构、工作环境、历史。在这个过程中要搞明白Java从源代码到最后虚拟机里面执行的一个过程是怎样的。
2.学习Java语法:
      Java里面只有50多个关键字和一些运算符。语法结构就只有顺序、条件、循环 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号