### Question:
FileUtils { public static Resource file2Resource(String filename) throws MalformedURLException { Path file = Paths.get(filename); Resource resource = new UrlResource(file.toUri()); if (resource.exists() || resource.isReadable()) { return resource; } else { logger.error("file can not read : {}", filename); } return null; }  static void copyFile(MultipartFile file, String destFilename); static Resource file2Resource(String filename); static String file2String(MultipartFile file);  }### Answer:
@Test public void testFile2Resource() throws IOException { String destFilename = rootPath + System.getProperty("file.separator") + "data.txt"; logger.info("destFilename: "+destFilename); File file = folder.newFile("resource.txt"); Resource resource = FileUtils.file2Resource(file.getAbsolutePath()); assertNotNull(resource); Resource resource1 = FileUtils.file2Resource(file.getAbsolutePath()+"abc"); assertNull(resource1); }