Created
August 16, 2012 22:41
-
-
Save pxpc2/3374283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package contrib; | |
| import javax.swing.*; | |
| import java.io.File; | |
| import java.nio.file.Path; | |
| import java.nio.file.Paths; | |
| import java.util.HashMap; | |
| import java.util.List; | |
| /** | |
| * @author pxpc2 | |
| * @version 1.0 | |
| * <p/> | |
| * Log merger, Contributor challenge 2 | |
| */ | |
| public class Logger { | |
| public String chosenDirectory; | |
| public List<Path> directoryFiles; | |
| public Logger() { | |
| chosenDirectory = JOptionPane.showInputDialog( | |
| "Enter with the path to another directory or to the absolute file"); | |
| File tF = new File(chosenDirectory); | |
| Path currentPath; | |
| if ((tF != null) && (tF.isDirectory())) { | |
| for (File f : tF.listFiles()) | |
| directoryFiles.add(Paths.get(f.getAbsolutePath())); | |
| } else if ((tF != null) && (tF.isFile())) { | |
| currentPath = Paths.get(tF.getAbsolutePath()); | |
| tF = null; | |
| directoryFiles.add(currentPath); | |
| } | |
| } | |
| /** | |
| * | |
| * @param files the files list | |
| * @return hashmap of to merge (key = fileOne, value = toMergeWithKey) | |
| */ | |
| public HashMap<Path, Path> getToMerge(List<Path> files) { | |
| HashMap<Path, Path> toMerge = new HashMap<Path, Path>(); | |
| for (int x = 0; x < files.size(); x++) { | |
| if (x != files.size() - 1) { | |
| if (files.get(x).getFileName().equals | |
| (files.get(x+1).getFileName())) { | |
| toMerge.put(files.get(x), files.get(x+1)); | |
| } | |
| } | |
| } | |
| return toMerge; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment