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

📄 main.java

📁 java 的关于web serive教程
💻 JAVA
字号:
/* * 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.JAXBElement;import javax.xml.bind.JAXBException;import javax.xml.bind.Marshaller;import javax.xml.bind.Unmarshaller;// import java content classes generated by binding compilerimport primer.po.*;/* * $Id: Main.java,v 1.1 2006/01/25 20:16:47 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 java content    // tree and marshal it back to a xml data        public static void main( String[] args ) {        try {            // create a JAXBContext capable of handling classes generated into            // the primer.po package            JAXBContext jc = JAXBContext.newInstance( "primer.po" );                        // create an Unmarshaller            Unmarshaller u = jc.createUnmarshaller();                        // unmarshal a po instance document into a tree of Java content            // objects composed of classes from the primer.po package.            JAXBElement poe =                 (JAXBElement)u.unmarshal( new FileInputStream( "po.xml" ) );	    PurchaseOrderType po = (PurchaseOrderType)poe.getValue();            // change the billto address            USAddress address = po.getBillTo();            address.setName( "John Bob" );            address.setStreet( "242 Main Street" );            address.setCity( "Beverly Hills" );            address.setState( "CA" );            address.setZip( new BigDecimal( "90210" ) );                        // create a Marshaller and marshal to a file            Marshaller m = jc.createMarshaller();            m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );            m.marshal( poe, System.out );                    } catch( JAXBException je ) {            je.printStackTrace();        } catch( IOException ioe ) {            ioe.printStackTrace();        }    }}

⌨️ 快捷键说明

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