Or use pub.file:getFile, with loadAs set to stream.
However, this only handles the first (and easiest) part of Nisha’s post: how to read the file as a stream.
The second part is the tough part: how to send EDI documents to TN via routeXML without using convertToValues. Since routeXML accepts a node (which must be an XML document) as its input and an EDI document is definitely not an XML document, you’ll have to write your own code to convert from EDI to something that routeXML can understand.
Why not just use convertToValue? It works, its modular (accepts multiple EDI document types), and its already built for you.
If the file is very large and the IS goes for a toss even after processing with ffiterator while convertToValues and or with Stream(streamToString), then I think splitting the file in small chunks and then validating ,routing and processing each chunk can be a way through to avoid loading of entire file. But I dont know how much can this be helpfull to nisha as splitting the the file into many smaller files would break the integrity of the records in file .
Just to clarify, streamToString will always load the complete file into memory. When using a stream for large file handling, it is important to not do anything that will read the entire stream of bytes into memory.