Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active December 14, 2023 09:58
Show Gist options
  • Save stevewithington/94daf471d55063249958 to your computer and use it in GitHub Desktop.
Save stevewithington/94daf471d55063249958 to your computer and use it in GitHub Desktop.
Mura CMS : JavaSettings LoadPaths example
<cfscript>
/*
Assuming you have downloaded and extracted the OpenCSV project from http://opencsv.sourceforge.net
you will then need to grab the file from /deploy/opencsv-2.x.jar file, and add it to one of your
registered javaSettingsLoadPaths directories.
You _may_ have to restart CF for the libraries to get registered.
*/
// full filesystem path to the file
csvFile = ExpandPath('#$.siteConfig('themeAssetPath')#/assets/files/sample.csv');
// container
csvData = [];
// FileReader
fileReader = CreateObject('java','java.io.FileReader');
fileReader.init(csvFile);
// ** This is the magic! **
// CF will scan your registered libs for you to load your object (OpenCSV)
csvReader = CreateObject('java','au.com.bytecode.opencsv.CSVReader');
csvReader.init(fileReader);
// the data
csvData = csvReader.readAll();
// release system resources
csvReader.close();
fileReader.close();
WriteDump(var=csvData);
</cfscript>
; add this to your /config/settings.ini.cfm
; it's just a comma-separated list of paths to your Java libraries
; but only _if_ you want to use something other than /requirements/lib
javaSettingsLoadPaths=/requirements/lib,/default/includes/themes/MuraBootstrap3/lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment