Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.StreamCorruptedException;

import java.util.ArrayList;

public class Main {
    public static synchronized ArrayList<double[]> readArrayListFromFile(String filename) {
        ObjectInputStream input;
        ArrayList<double[]> x = null;
        try {
            input = new ObjectInputStream(new FileInputStream(new File(filename)));
            Object obj = input.readObject();
            if (obj != null)
                x = (ArrayList<double[]>) input.readObject();
            input.close();
            return x;
        } catch (StreamCorruptedException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        return x;
    }
}