I keep getting the following error whenever I try to upload a file in my test environment:

2019-05-11 17:00:59.934 DEBUG 17380 --- [io-8080-exec-10] com.test.api.sermon.SermonService         : Writing file to local storage as environment is not LIVE
2019-05-11 17:00:59.934 DEBUG 17380 --- [io-8080-exec-10] com.test.api.sermon.SermonService         : File Path: classpath://resources/upload/2019-05-11~Test~Test1.mp3
java.io.IOException: The filename, directory name, or volume label syntax is incorrect at java.io.WinNTFileSystem.createFileExclusively(Native Method)

This my code:

if(activeProfile.equals("dev") || activeProfile.equals("uat")) {
    LOGGER.debug("Writing file to local storage as environment is not LIVE");
    sermonPath = applicationConfiguration.getSermonPath() + fileName;
    if(LOGGER.isDebugEnabled()){
        LOGGER.debug("File Path: " + sermonPath);
    }
    sermonFile = new File(sermonPath);
    sermonFile.createNewFile();
    FileOutputStream fOut = new FileOutputStream(sermonFile);
    fOut.write(sermon.getBytes());
    fOut.close();
}

The directory exists in my classpath:

enter image description here

My Spring config is as follows:

application.sermon_path=classpath://resources/upload/

Is there any reason why this is happening?

0 Answers