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 {
            log.error("File can not be read, fileName:{}", filename);
        }
        return null;
    }
@Test
    public void testFile2Resource() throws IOException {

        // Define dest file path
        String destFilename = rootPath + System.getProperty("file.separator") + "resource.txt";
        logger.info("destFilename: " + destFilename);

        // Define test resource
        File file = new File(destFilename);
        org.apache.commons.io.FileUtils.writeStringToFile(file, "test data", Charset.defaultCharset());

        // Invoke file2Resource and test not null
        Resource resource = FileUtils.file2Resource(file.toString());
        Assertions.assertNotNull(resource);

        // Invoke file2Resource and test null
        Resource resource1 = FileUtils.file2Resource(file + "abc");
        Assertions.assertNull(resource1);

    }