1

My application downloads some plain CSV files from a remote server, and I want to store them into resource/files path. The files folder is initially empty, and when I try to select the folder with the getResource method of the classLoader, I always get null as the return value.

URL localUrl = MyClass.class.getCassLoader().getResource("files"); // = null

But once a file is present in the files folder the above code gives me the location of the folder.

Is there a way in Java to select an empty folder within the resource folder? I am using Java 11.

wero026
  • 1,187
  • 2
  • 11
  • 23
  • 1
    I guess your build process is removing the empty directory. It's irrelevant anyway because you can't write to that directory. – Michael Feb 18 '19 at 12:08
  • 3
    You cannot use the classloader to *store* files. It should be treated as read-only. Use some other way to determine a location on the filesystem where you can cache stuff. – Thilo Feb 18 '19 at 12:11
  • Have you tried `/files/` ? – KunLun Feb 18 '19 at 12:12
  • Try this, hopefully it should solve your problem. https://stackoverflow.com/a/50387930/5543072 – Sagar P. Ghagare Feb 18 '19 at 12:13

0 Answers0