The code below demostrate reading in a file and consuming the content.
NOTE: This is not the recommend way for setting up a channel that processes HL7 messages. The use of HL7 is just to demostrate something that is familier. A better way to consume HL7 messages stored in a directory is to configure the source node.
//Read in the file. The qie.readfile returns a byte[]
var fileBytes = qie.readFile(new java.io.File("C:\\HL7\\in\\testFile.hl7"));
//Convert the bytes to a string
var stringifiedFileContents = new java.lang.String(fileBytes);
qie.debug("File contents: " + stringifiedFileContents);
//Convert the string to an HL7 message
var hl7Message = qie.parseHL7String(stringifiedFileContents);
qie.debug("The result of calling getNode: " + hl7Message.getNode('MSH-3'));
The output after running the above code:
Reading file: C:\HL7\in\testFile.hl7
File contents: MSH|^~\&|Just a test|
The result of calling getNode: Just a test
Also see this related question: https://www.qvera.com/kb/index.php/402/how-to-convert-strings-to-byte-and-back-again?show=402#q402