I have the following line of code:
InputStreamReader isr = new InputStreamReader(MethodHandles.lookup().lookupClass().getResourceAsStream(csvFile));
could someone explain to a newbe:
MethodHandles.lookup()
lookupClass()
getResourceasStream()
the code works and accesses a csv file located in a jar. I just don't understand what each of the methods is doing
I was able to simplify the line to:
InputStreamReader isr = new InputStreamReader (SQLUtilPROD.class.getResourceAsStream (csvFile));
but still confused. What does SQLUtilProd.class do? and how does getResourceAsStream know to get the file from the jar? What happens if you have multiple jars?
Not sure but I think we use SQLUtil.class to get the class object which in turns gives us access to classLoader which getResourceAsStream uses to locate the file.
If that's true where does classLoader define the path to include the jar?