Read Java Bean encoded file to Object - Android XML

Android examples for XML:JAXB

Description

Read Java Bean encoded file to Object

Demo Code


//package com.java2s;
import java.beans.XMLDecoder;

import java.io.*;

public class Main {
    public static void main(String[] argv) throws Exception {
        String filename = "java2s.com";
        System.out.println(Read(filename));
    }//w w  w.  j a va2 s.co  m

    public static Object Read(String filename) throws FileNotFoundException {
        XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(
                new FileInputStream(filename)));
        Object obj = decoder.readObject();
        decoder.close();
        return obj;
    }
}

Related Tutorials