?? domclient.java
字號:
package dom;
import java.io.*;
import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.*;
import org.xml.sax.*;
import weblogic.apache.xml.serialize.*;
public class DomClient{
public static void main(String argv[]){
int LineWidth = 20;
int Indent = 4;
String encoding = "UTF-8";
BufferedInputStream bis=null;
DocumentBuilderFactory fact;
DocumentBuilder db;
Document doc=null;
try{
FileInputStream filein=new FileInputStream(argv[0]);
bis = new BufferedInputStream(filein);
}catch(FileNotFoundException e){
System.out.println("get File failed");
}
try{
fact = DocumentBuilderFactory.newInstance();
db = fact.newDocumentBuilder();
doc = db.parse(new InputSource(bis));
}catch(ParserConfigurationException e){
System.out.println("DocumentBuilderFactory Exception");
}catch(SAXException e){
System.out.println("SAXException Exception");
}catch(IOException e){
System.out.println("IOException Exception");
}
OutputFormat of = new OutputFormat();
of.setEncoding(encoding);
of.setLineWidth(LineWidth);
of.setIndent(Indent);
XMLSerializer xs = new XMLSerializer(System.out, of);
System.out.println("START DOCUMENT\n");
try {
xs.serialize(doc);
}
catch(Exception e) {
System.out.println(e);
}
System.out.println("\nEND DOCUMENT");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -