@Test void testGetFileNotExists() { String fileName = "unknownFile"; assertThrows(FileNotFoundException.class, () -> fileStore.getFile(fileName)); }
public File getFile(String fileName) throws IOException { validatePathname(fileName); String pathname = storageDir + separator + fileName; File file = new File(pathname); if (!file.exists()) { throw new FileNotFoundException(pathname); } if (!file.isFile()) { throw new IOException('\'' + pathname + '\'' + " is not a file"); } return file; }
FileStore { public File getFile(String fileName) throws IOException { validatePathname(fileName); String pathname = storageDir + separator + fileName; File file = new File(pathname); if (!file.exists()) { throw new FileNotFoundException(pathname); } if (!file.isFile()) { throw new IOException('\'' + pathname + '\'' + " is not a file"); } return file; } }
FileStore { public File getFile(String fileName) throws IOException { validatePathname(fileName); String pathname = storageDir + separator + fileName; File file = new File(pathname); if (!file.exists()) { throw new FileNotFoundException(pathname); } if (!file.isFile()) { throw new IOException('\'' + pathname + '\'' + " is not a file"); } return file; } FileStore(String storageDir); }
FileStore { public File getFile(String fileName) throws IOException { validatePathname(fileName); String pathname = storageDir + separator + fileName; File file = new File(pathname); if (!file.exists()) { throw new FileNotFoundException(pathname); } if (!file.isFile()) { throw new IOException('\'' + pathname + '\'' + " is not a file"); } return file; } FileStore(String storageDir); FileStore inSubdir(String subdir); boolean createDirectory(String dirName); void deleteDirectory(String dirName); File store(InputStream is, String fileName); void move(String sourceDir, String targetDir); File getFile(String fileName); File getFileUnchecked(String fileName); void delete(String fileName); String getStorageDir(); }
FileStore { public File getFile(String fileName) throws IOException { validatePathname(fileName); String pathname = storageDir + separator + fileName; File file = new File(pathname); if (!file.exists()) { throw new FileNotFoundException(pathname); } if (!file.isFile()) { throw new IOException('\'' + pathname + '\'' + " is not a file"); } return file; } FileStore(String storageDir); FileStore inSubdir(String subdir); boolean createDirectory(String dirName); void deleteDirectory(String dirName); File store(InputStream is, String fileName); void move(String sourceDir, String targetDir); File getFile(String fileName); File getFileUnchecked(String fileName); void delete(String fileName); String getStorageDir();  }