-
Notifications
You must be signed in to change notification settings - Fork 3
/
VectorSaveAndLoad.java
61 lines (47 loc) · 1.73 KB
/
VectorSaveAndLoad.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package EyeTracking;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList;
/**
*
* @author XXX
*/
public class VectorSaveAndLoad {
public static void saveVectorCoordinates(Vector[] vecArray, String fileName) {
try {
XMLEncoder xmlEncoder = new XMLEncoder(new FileOutputStream(fileName + ".vec"));
xmlEncoder.writeObject(vecArray);
xmlEncoder.close();
} catch (Exception e) {
System.out.println("VectorSave error");
e.printStackTrace();
}
}
public static Vector[] loadVectorCoordinates(String fileName) throws FileNotFoundException {
XMLDecoder dec = new XMLDecoder(new FileInputStream(fileName + ".vec"));
Vector[] b = (Vector[]) dec.readObject();
return b;
}
public static void saveEstimationResults(ArrayList<EstimationResults> er, String fileName) {
try {
XMLEncoder xmlEncoder = new XMLEncoder(new FileOutputStream(fileName + ".vec"));
xmlEncoder.writeObject(er);
xmlEncoder.close();
} catch (Exception e) {
e.printStackTrace();
System.out.println(" Estimation Resaults save error ");
}
}
public static ArrayList<EstimationResults> loadEstimatedResults(String fileName) throws FileNotFoundException {
XMLDecoder dec = new XMLDecoder(new FileInputStream(fileName + ".vec"));
ArrayList<EstimationResults> b = (ArrayList<EstimationResults>) dec.readObject();
return b;
}
}