Last active
November 11, 2019 18:27
-
-
Save jensmeder/b2c3f641fbb48ebffcedc38779b36251 to your computer and use it in GitHub Desktop.
Medium
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
import java.io.IOException; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.StandardCopyOption; | |
import java.util.Map; | |
import java.util.List; | |
public class Photos { | |
private final Path source; | |
private final Path destination; | |
public Photos(Path source, Path destination) throws IOException { | |
this.source = source; | |
this.destination = destination; | |
importAll(); | |
} | |
public Photos(String source, String destination) throws IOException { | |
this.source = Path.of(source); | |
this.destination = Path.of(destination); | |
importAll(); | |
} | |
public String[] list() throws SecurityException { | |
return this.source.toFile().list((dir, name) -> name.toLowerCase().endsWith(".jpeg")); | |
} | |
private void importAll() throws IOException { | |
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment