⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdomtwo.java

📁 本站资料仅为大家学习之用
💻 JAVA
字号:
/*
 * (C) Copyright IBM Corp. 2003.  All rights reserved.
 *
 * US Government Users Restricted Rights Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 *
 * The program is provided "as is" without any warranty express or
 * implied, including the warranty of non-infringement and the implied
 * warranties of merchantibility and fitness for a particular purpose.
 * IBM will not be liable for any damages suffered by you as a result
 * of using the Program. In no event will IBM be liable for any
 * special, indirect or consequential damages or lost profits even if
 * IBM has been advised of the possibility of their occurrence. IBM
 * will not be liable for any third party claims against you.
 */

import java.io.File;
import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;

public class JdomTwo
{
  public static void main(String[] argv)
  {
    if (argv.length == 0 ||
        (argv.length == 1 && argv[0].equals("-help")))
    {
      System.out.println("\nUsage:  java JdomTwo uri");
      System.out.println("   where uri is the URI of your XML document.");
      System.out.println("   Sample:  java JdomTwo sonnet.xml");
      System.out.println("\nUses the JDOM API to parse an XML document, " +
                         "then write it back to the console.");
      System.out.println("This code is different from JDOMOne because it " +
                          "ignores whitespace.");
      System.exit(1);
    }

    try
    {
      SAXBuilder sb = new SAXBuilder();
      Document doc = sb.build(new File(argv[0]));
      XMLOutputter xo = new XMLOutputter();
      xo.setTrimAllWhite(true);
      xo.output(doc, System.out);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -