Java FileInputStream Read readFile(String filename)

Here you can find the source of readFile(String filename)

Description

read File

License

Apache License

Declaration

public static Object readFile(String filename) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    private static final String DATA_DIR = "data/";

    public static Object readFile(String filename) {
        FileInputStream fis = null;
        ObjectInputStream ois = null;
        Object o = null;//  www.  java  2s  . co m

        try {
            fis = new FileInputStream(DATA_DIR + filename);
            ois = new ObjectInputStream(fis);

            try {
                o = ois.readObject();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                ois.close();
            }

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return o;
    }
}

Related

  1. readFile(String filename)
  2. readFile(String fileName)
  3. readFile(String fileName)
  4. readFile(String filename)
  5. readFile(String filename)
  6. readFile(String fileName)
  7. readFile(String fileName, String charset)
  8. readFile(String filePath)
  9. readFile(String filePath)