Java FileInputStream Read readFile(String filePathName)

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

Description

read File

License

Open Source License

Declaration

public static Object readFile(String filePathName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {

    public static Object readFile(String filePathName) {
        ObjectInputStream oin = null;
        try {//www  . ja v a2 s.  co  m
            File file = new File(filePathName);
            if (!file.exists()) {
                file.createNewFile();
            }
            oin = new ObjectInputStream(new BufferedInputStream(new FileInputStream(file)));
            Object obj = oin.readObject();

            return obj;
        } catch (Exception err) {
            err.printStackTrace();
        } finally {
            try {
                oin.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return null;
    }
}

Related

  1. readFile(String filePath)
  2. readFile(String filePath)
  3. readFile(String filePath)
  4. readFile(String filePath)
  5. readFile(String filePath)
  6. readFile(String fname)
  7. readFile(String fname)
  8. readFile(String fname)
  9. readFile(String imageName)