import java.beans.*; import java.io.*; /** * ReadXML deserializes an instance of from XML. */ public class ReadXML { public static void main(String[] args) { // Check command-line args. if (args.length < 1) { System.out.println("Usage: ReadXML file"); System.exit(0); } // Get file name. String file = args[0]; try { // Create file input stream. FileInputStream fstream = new FileInputStream(file); try { // Create XML decoder. XMLDecoder istream = new XMLDecoder(fstream); try { // Read object. Object obj = istream.readObject(); System.out.println(obj); } finally { // Close object stream. istream.close(); } } finally { // Close file stream. fstream.close(); } } catch(Exception ex) { System.out.println(ex); } } }