/
AbstractExporter.java
51 lines (41 loc) · 1.08 KB
/
AbstractExporter.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
/*
This file is a part of Angry IP Scanner source code,
see http://www.angryip.org/ for more information.
Licensed under GPLv2.
*/
package net.azib.ipscan.exporters;
import net.azib.ipscan.config.Labels;
import java.io.*;
/**
* Helper base class of all built-in exporters
*
* @author Anton Keks
*/
public abstract class AbstractExporter implements Exporter {
protected PrintWriter output;
protected boolean append;
public String getName() {
return Labels.getLabel(getId());
}
public void shouldAppendTo(File file) {
this.append = true;
}
public void start(OutputStream outputStream, String feederInfo) throws IOException {
output = new PrintWriter(new OutputStreamWriter(outputStream));
}
public void end() throws IOException {
// this does the flush internally as well
if (output.checkError())
throw new IOException();
}
@Override public void nextAddressResults(Object[] results) throws IOException {
}
public Exporter clone() {
try {
return (Exporter) super.clone();
}
catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}
}