/** * Make the constructor private for a singleton. */ private Options() { // Create the path to the image directory. File imageDirectory = new File(getDirectoryPath()); // Create the image directory. imageDirectory.mkdirs(); } }
/** * Clears the filter directories. */ private void deleteDownloadedImages() { int deletedFiles = deleteSubFolders(Options.instance().getDirectoryPath()); System.out.println(TAG + ": " + deletedFiles + " previously downloaded file(s) deleted"); }
/** * Store the image on the local file system. * * @return The stored image file. */ public File store() { // Get a reference to the file in which the image will be // stored. File imageFile = new File(new File(Options.instance().getDirectoryPath()), getFileName()); // Store the image using try-with-resources try (FileOutputStream outputFile = new FileOutputStream(imageFile)) { // Write the image to the output file. PlatSpec.writeImageFile(outputFile, this); return imageFile; } catch (Exception e) { e.printStackTrace(); return null; } } }