main.java

来自「java 的关于web serive教程」· Java 代码 · 共 59 行

JAVA
59
字号
/* * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ import java.io.FileInputStream;import java.io.IOException;import java.math.BigDecimal;import javax.xml.bind.JAXBContext;import javax.xml.bind.JAXBException;import javax.xml.bind.Marshaller;import javax.xml.bind.Unmarshaller;import java.util.List;// import java content classes generated by binding compilerimport example.*;/* * $Id: Main.java,v 1.1 2006/01/25 20:16:02 jendrock Exp $ * * Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. *  * This software is the proprietary information of Sun Microsystems, Inc.   * Use is subject to license terms. *  */ public class Main {        // This sample application demonstrates how to modify a collection    // in a java content tree and marshal it back to xml data        public static void main( String[] args ) {        try {            // create a JAXBContext capable of handling classes generated into            // the example package            JAXBContext jc = JAXBContext.newInstance( "example" );                        // create an Unmarshaller            Unmarshaller u = jc.createUnmarshaller();                        // unmarshal a FooBar instance document into a tree of Java content            // objects composed of classes from the example package.            Object fbe =  u.unmarshal( new FileInputStream( "example.xml" ) );            // create a Marshaller and marshal to a file            Marshaller m = jc.createMarshaller();            m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );            m.marshal( fbe, System.out );                    } catch( JAXBException je ) {            je.printStackTrace();        } catch( IOException ioe ) {            ioe.printStackTrace();        }    }}

⌨️ 快捷键说明

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