How would I do something like this in intelliJ IDEA
File file = new File("C:\Users\Account\Documents\ProjectFolder\ResourceFolder\image");
But not have to enter the whole file path in. I'm pretty sure there is a way, and I'm fairly certain it has something to do with adding it to my build path. I know how to do that in Eclipse but not in intelliJ.
Thanks in advance!
To do this, open the File > Project Structure dialog, select the Modules tab, and click on the resources folder. The result will be as shown below. Your application can now access resources from the resources folder.
Right-click the pasted image in the Project tool window and select Copy | Path From Source Root. In the class in which you want to use the image, place the caret at the necessary line and press Ctrl+V to paste the path to the image. Run the class to make sure that the image is inserted correctly.
If you just want to copy the file path you can use Ctrl + Shift + C . You can also search for action with (Ctrl + Shift + A) (for mac Command + Shift + A) and then it will show you the Keyboard shortcut for particular action. If you want to change the Keymap you can open setting page and search for Keymap.
This works when running inside and outside of a Jar file. PathMatchingResourcePatternResolver r = new PathMatchingResourcePatternResolver(); Resource[] resources = r. getResources("/myfolder/*"); Then you can access the data using getInputStream and the filename from getFilename .
You should use Java resource loading system. This is not depending on your IDE. Once you have marked a folder as resource folder in IntelliJ, it is available in your code as via resource loader.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With