-
Notifications
You must be signed in to change notification settings - Fork 0
/
TxtWriter.java
49 lines (44 loc) · 1.11 KB
/
TxtWriter.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
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.util.Collection;
import java.util.LinkedList;
//File;
public class TxtWriter
{
FileWriter f;
BufferedWriter writeTo;
LinkedList <Collection<Number>>columns;
LinkedList <String>colNames;
int anonCols;
public TxtWriter(String fileName)
{
try
{
FileWriter fstream = new FileWriter(fileName);
writeTo = new BufferedWriter(fstream);
columns = new LinkedList<Collection<Number>>();
anonCols=0;
}
catch (java.io.IOException e)
{
System.out.println("Error in DataWriter[constructor]: "+e.getMessage());
System.exit(0);
}
}
public boolean addColumn(Collection<Number> c)
{
anonCols++;
boolean addBool = columns.add(c);
if (addBool == false)
{
return false;
}
addBool = colNames.add("");
if (addBool == false)
{
columns.remove(c);
return false;
}
return true;
}
}