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

📄 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.util.Iterator;import java.util.List;import javax.xml.bind.JAXBContext;import javax.xml.bind.JAXBElement;import javax.xml.bind.JAXBException;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:59 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 unmarshal an instance    // document into a Java content tree and access data contained within it.        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<?> poElement = 		(JAXBElement<?>)u.unmarshal( new FileInputStream( "po.xml" ) );            PurchaseOrderType po = (PurchaseOrderType)poElement.getValue();                	                // examine some of the content in the PurchaseOrder            System.out.println( "Ship the following items to: " );                        // display the shipping address            USAddress address = po.getShipTo();            displayAddress( address );                        // display the items            Items items = po.getItems();            displayItems( items );                    } catch( JAXBException je ) {            je.printStackTrace();        } catch( IOException ioe ) {            ioe.printStackTrace();        }    }        public static void displayAddress( USAddress address ) {        // display the address        System.out.println( "\t" + address.getName() );        System.out.println( "\t" + address.getStreet() );         System.out.println( "\t" + address.getCity() +                            ", " + address.getState() +                             " "  + address.getZip() );         System.out.println( "\t" + address.getCountry() + "\n");     }        public static void displayItems( Items items ) {        // the items object contains a List of primer.po.ItemType objects        List itemTypeList = items.getItem();                        // iterate over List        for( Iterator iter = itemTypeList.iterator(); iter.hasNext(); ) {            Items.Item item = (Items.Item)iter.next();             System.out.println( "\t" + item.getQuantity() +                                " copies of \"" + item.getProductName() +                                "\"" );         }    }}

⌨️ 快捷键说明

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