read File name using JavaBean XML Decoder - Java XML

Java examples for XML:XML Java Bean

Description

read File name using JavaBean XML Decoder

Demo Code


//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;
    }
}

Related Tutorials