just now I realised that the Java Snippet node actually allows the data type “Path” as output. I’ve been waiting for that feature for a while now, because it will allow me to omit the String to Path nodes. However, I can’t figure out how to convert the data type properly. Assigning a string obviously doesn’t work and gives this error message instead:
Error in line 36: Type mismatch: cannot convert from java.lang.String to org.knime.filehandling.core.connections.FSLocation
Didn’t find anything online. Intended path is local only, like “C:\Users\Thyme\my_file.xlsx”. If it can’t be done, that’s ok.
BR, T
Yes, that’s the string representation of Path objects. Or so I think, I’m not an actual Java programmer . Building a string like that is easy, but unfortunately of no use, since it’s the wrong data type. I’m looking for the method that accepts a string and returns the path object.
The KNIME documentation doesn’t cover such a niche application (which is how it should be).
I just had the idea of looking into the source code of the StringToPath Node (it does what I want, so the answer gotta be in there). NodePit links to the source. This is unfamiliar territory though, not sure if I’ll have any success with that. StringToPath source
/** Category for local "convenience" file system(s) */
LOCAL("Local File System"),
/** Category for relative "convenience" file systems */
RELATIVE("Relative to"),
/** Category for "convenience" file systems that access mountpoints */
MOUNTPOINT("Mountpoint"),
/** Category for "convenience" file system(s) that access only URLs */
CUSTOM_URL("Custom/KNIME URL"),
/** Category for file systems that need to be connected via input port. */
CONNECTED("");
works like a charm, it’s exactly what I’ve been looking for. Thank you!
Some extra information for future people:
KNIME imports the libraries it needs to handle system variables on its own. Once you add a Path column as input or output, this will be added to the system imports automagically: