1 package eu.fbk.knowledgestore.populator.naf;
2
3 import java.io.BufferedReader;
4 import java.io.BufferedWriter;
5 import java.io.File;
6 import java.io.FileReader;
7 import java.io.FileWriter;
8 import java.io.IOException;
9 import java.util.Hashtable;
10 import java.util.Set;
11
12 public class getToBeProcessed {
13
14
15
16
17
18 public static void main(String[] args) throws IOException {
19 Hashtable<String,String> all = new Hashtable<String, String>();
20 Hashtable<String,String> sub = new Hashtable<String, String>();
21 Hashtable<String,String> intersect = new Hashtable<String, String>();
22 String ap="/Users/qwaider/Documents/Projects/NWR-June2015/knowledgestore/ks-distribution/target/" +
23
24 "xmls.txt";
25 String sp="/Users/qwaider/Documents/Projects/NWR-June2015/knowledgestore/ks-distribution/target/" +
26
27 "processedxmls.txt";
28 String intersectp="/Users/qwaider/Documents/Projects/NWR-June2015/knowledgestore/ks-distribution/target/" +
29
30 "toBeProcessedXMLS.txt";
31 readFile(ap,all);
32 readFile(sp,sub);
33 intersect(intersectp,all,sub,intersect);
34 System.out.println("all: "+all.size()+"-sub:"+sub.size()+"-intersect:"+intersect.size());
35 }
36
37 private static void intersect(String intersectp, Hashtable<String, String> all,
38 Hashtable<String, String> sub,Hashtable<String, String> intersect) throws IOException {
39
40 File file = new File(intersectp);
41
42
43 if (!file.exists()) {
44 file.createNewFile();
45 }
46
47 FileWriter fw = new FileWriter(file.getAbsoluteFile());
48 BufferedWriter bw = new BufferedWriter(fw);
49 for(String link : all.keySet()){
50 if(!sub.containsKey(link)){
51 bw.write(link+"\n");
52 bw.flush();
53 if(!intersect.containsKey(link))
54 intersect.put(link, "");
55
56 }
57
58 }
59 bw.close();
60 }
61
62 static void readFile(String filepath,Hashtable<String,String> fls){
63 BufferedReader br = null;
64
65 try {
66
67 String sCurrentLine;
68
69 br = new BufferedReader(new FileReader(filepath));
70
71 while ((sCurrentLine = br.readLine()) != null) {
72 fls.put(sCurrentLine, "");
73
74 }
75
76 } catch (IOException e) {
77 e.printStackTrace();
78 } finally {
79 try {
80 if (br != null)br.close();
81 } catch (IOException ex) {
82 ex.printStackTrace();
83 }
84 }
85 }
86
87 }