Java examples for XML:XML Java Bean
read File name using JavaBean XML Decoder
//package com.java2s; import java.beans.XMLDecoder; import java.io.BufferedInputStream; import java.io.FileInputStream; public class Main { public static void main(String[] argv) throws Exception { String filename = "java2s.com"; System.out.println(read(filename)); }//from w ww .ja va 2s . c o m public static Object read(String filename) throws Exception { XMLDecoder decoder = new XMLDecoder(new BufferedInputStream( new FileInputStream(filename))); Object o = decoder.readObject(); decoder.close(); return o; } }