Java project build by Gradle.
I want to create file in \build\resources\main\db\sqlite\insert-data.sql
I try this:
protected File getDestinationFile(String baseDir) {
try {
URL testURL = ClassLoader.getSystemClassLoader().getResource("db/sqlite");
String pathName = testURL + "/" + DEFAULT_FILE_NAME_INSERT_DATA;
logger.debug("pathName = " + pathName);
File newFile = new File(pathName);
newFile.createNewFile();
return newFile;
} catch (IOException e) {
logger.error(e.getMessage(), e);
return null;
}
}
But I get error on runtime:
[17.06.2022 00:19:38.223] MyClass.getDestinationFile(SQLiteStrategy.java:170) ERROR:
java.io.IOException:
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:1012)