### AdditionJar with Files

A way to load files (resources) from an Additional Jar file located in the Additional Libraries folder.
For this example, the additional jar file, B4JHowToAdditionalFiles.jar, contains two text files and an image in the Folder Files.
To create B4JHowToAdditionalFiles.jar, zip the folder AdditionalFiles to B4JHowToAdditionalFiles.zip.
The B4JHowToAdditionalFiles.zip has file structure:
[Files]
[Files]image-Exit.png
[Files]resource1.txt
[Files]resource2.txt
Rename B4JHowToAdditionalFiles.zip to jar and copy B4JHowToAdditionalFiles.jar to the B4J Additional Libraries folder.
Add Project Attributes, #AdditionalJar: B4JHowToAdditionalFiles.
#Region Project Attributes
'Add additional jars
'The file B4JHowToAdditionalFiles.jar contains resources located in the Files folder of the file B4JHowToAdditionalFiles.jar:
'Files/resource1.txt, Files/resource2.txt
'To load a resource, use File.ReadString(File.DirAssets, "resource1.txt").
'Note: do not add the Files folder in the filename as the folder is given by File.DirAssets.
'Note: The examples uses text files and an image.
#AdditionalJar: B4JHowToAdditionalFiles
#End Region
`Sub Process_Globals
...
Private btnLoadTextResource1 As Button
Private btnLoadTextResource2 As Button
Private TextArea1 As TextArea
Private btnLoadImageResource As Button
Private ImageView1 As ImageView
Private btnClearImageResource As Button
...
End Sub`
`Sub btnLoadTextResource1_Action
Try
TextArea1.Text = File.ReadString(File.DirAssets, "resource1.txt") 'ignore
Catch
Log(LastException)
End Try
End Sub`
`Sub btnLoadTextResource2_Action
Try
TextArea1.Text = File.ReadString(File.DirAssets, "resource2.txt") 'ignore
Catch
Log(LastException)
End Try
End Sub`
`Sub btnLoadImageResource_Action
Try
ImageView1.SetImage(fx.LoadImage(File.DirAssets, "image-exit.png")) 'ignore
Catch
Log(LastException)
End Try
End Sub`
`Sub btnClearImageResource_Action
Try
ImageView1.SetImage(Null) 'ignore
Catch
Log(LastException)
End Try
End Sub`

Changed: , Category: Jar, File: T6C204M1496.htm, ID: 1496