-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSVWriter.java
More file actions
executable file
·58 lines (55 loc) · 1.59 KB
/
CSVWriter.java
File metadata and controls
executable file
·58 lines (55 loc) · 1.59 KB
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
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import com.google.common.eventbus.*;
class status {
srvInfo item;
CSVWriter writer;
public status(CSVWriter w) {
item = new srvInfo();
writer=w;
}
@Subscribe
public void recvStatus(srvInfo in){
item = in;
item.toString();
writer.write(item);
}
}
public class CSVWriter implements Runnable{
private EventBus eb;
private Writer out;
private CSVPrinter printer;
public CSVWriter(EventBus eventbus){
eb = eventbus;
eb.register(new status(this));
try {
out = new FileWriter("scores.csv",true);
printer = new CSVPrinter(out,CSVFormat.EXCEL); // .withHeader("Server Address","Server Name","Address","Host Name","User Claimed Server Name","Claimed Date/Time","Correct Date/Time","Is Reachable","HTTP Up","HTTP Status Code","Web Server","Powered By")
printer.printRecord("");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
// TODO Auto-generated method stub
}
public void write(srvInfo item){
try {
printer.printRecord(item.serverAddress,item.serverName,item.address,item.hostName,item.claimedHostName,item.dateTime,item.correctDateTime,item.isReachable,item.HTTPWorking,item.httpStatusCode,item.websrv,item.poweredBy);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
printer.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}