![]() Throw new Exception("resource not found: " + respath) ![]() The following code snippet shows how to load resources packed thus into the jar or war file: String respath = "/poems/Frost.txt" You can access these files and folders from your java code as shown below. Maven packs all the files and folders under main/resources into the jar file at the the root. In this article, we show you how to load these resources when the program is running. When the software is executed, it may need to load the contents of these files for some kind of processing - may be properties, sql statements, etc. These files may include configuration files, scripts and other resources needed during run time. You can catch the exception when you want to handle any of these cases.When you build a java project and pack it into a jar (or a war), the files under the resources folder are included into the jar. This method throws an exception if the file does not exist or cannot be accessed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |