Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws IOException, ClassNotFoundException {
- if(args.length < 1) {
- System.err.println("Használat:");
- System.err.println(" java " + Ex1CreateIndex.class.getName() + " <index-file> <szavak>");
- System.exit(-1);
- }
- File indexFile = new File(args[0]);
- Ex1CreateIndex idx = new Ex1CreateIndex(indexFile);
- Set<File> files = new HashSet<File>();
- for(int i = 0; i< args.length;i++) {
- if(i == 0)
- continue;
- String word = args[i];
- Map<File, Integer> a = idx.getOccurences(word);
- if(i == 1) {
- files.addAll(a.keySet());
- } else {
- Set<File> ofiles = a.keySet();
- Set<File> delete = new HashSet<>();
- for(File f : ofiles) {
- boolean found = false;
- for(File file2 : ofiles) {
- if(f.getAbsolutePath().equals(file2.getAbsolutePath())) {
- found = true;
- break;
- }
- }
- if(!found) {
- delete.add(f);
- }
- }
- files.removeAll(delete);
- }
- for(File file : files) {
- System.out.println(file.getAbsoluteFile());
- }
- }
- System.out.println("-----");
- for(int i = 0; i< args.length;i++) {
- if(i == 0)
- continue;
- String word = args[i];
- Map<File, Integer> a = idx.getOccurences(word);
- System.out.println(word + ": " + a.keySet());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement