Deserializing A Bean From XML

 
 
This java source code is about Deserializing a Bean from XML......
 
 
  1. // Deserialize an object

  2.     try {

  3.         XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(

  4.             new FileInputStream("infilename.xml")));

  5.    

  6.         // MyClass is declared in e7 Serializing a Bean to XML

  7.         MyClass o = (MyClass)decoder.readObject();

  8.         decoder.close();

  9.    

  10.         // Use the object

  11.         int prop = o.getProp();     // 1

  12.         int[] props = o.getProps(); // [1,2,3]

  13.     } catch (FileNotFoundException e) {

  14.     }

  15.  

  16. Here is the XML data being deserialized:

  17.     <?xml version="1.0" encoding="UTF-8"?>

  18.     <java version="1.4.0" class="java.beans.XMLDecoder">

  19.         <object class="MyClass">

  20.             <void property="prop">

  21.                 <int>1</int>

  22.             </void>

  23.             <void property="props">

  24.                 <array class="int" length="3">

  25.                     <void index="0">

  26.                         <int>1</int>

  27.                     </void>

  28.                     <void index="1">

  29.                         <int>2</int>

  30.                     </void>

  31.                     <void index="2">

  32.                         <int>3</int>

  33.                     </void>

  34.                 </array>

  35.             </void>

  36.         </object>

  37.     </java>
 
Copy to Clipboard      Download code as Text Format
 
  Date entered : 17th Feb 2007
  Rating : No Rating
  Accessed  :  5379
  Submitted by :  javabill
 
   Add Comment  Printer friendly
   View All Comments  Email to a friend
   Add to my Favourites Download PDF version
   Rating  
 
                 Click each image to add
this page to each site.
 
 
 
Comments Available

    No comment available at the moment.Be the first one to make a comment

 
Related JSP Source Codes
Database error: Invalid SQL: select FLOOR( AVG(b.rating)) as avg_rating,a.sourcecode_id sourcecode_id ,title,description,author,category_id,skill_level,reference,reference_mail,reference_url,a.user_id user_id,date_entered,source,accessed,dev_id,file_url,total_comments,instruction,registered,authorised,fld_deletemark,fld_code_version,fld_searchkeyword,fld_code_status,category_id from tbl_sourcecode a LEFT JOIN tbl_sourcecodecomment b ON a.sourcecode_id = b.sourcecode_id LEFT JOIN tbl_codecategory c ON a.category_id = c.fld_categoryID where a.fld_deletemark = 'N' AND a.fld_enable_disable= 'Y' AND a.authorised='Y' AND c.fld_groupIDFK='4' AND a.sourcecode_id!='1282' GROUP BY a.sourcecode_id order by a.sourcecode_id DESC limit 0, 5
MySQL Error: 1030 (Got error 122 from storage engine)
Session halted.
Warning: Unknown(): write failed: Disk quota exceeded (122) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0