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.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.IOException;

import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import java.util.ArrayList;

public class Main {
    public static synchronized void writeArrayListToFile(ArrayList<double[]> x, String filename) {
        //        double  []x  = {1,2,4};
        //        String filename = "data.dat";
        ObjectOutput out = null;

        try {
            out = new ObjectOutputStream(new FileOutputStream(new File(filename)));
            out.writeObject(x);
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}