I have this expression to print the first N chars of the flow file content. The problem is when the content length is less than N. What's a good way to say "up to first N chars". That is I will not get an index out of bounds error when the size is less than N.
${incoming_content.0:substring(0,100)}
Here my N=100
Thank you.
If the content of your flow files are not too big, you can use ExtractText to convert contents of flowfile as attribute and then use UpdateAttribute processor to run following logic
${incoming.0:length():le(100):ifElse(${incoming.0},${incoming.0:substring(0,100)})}
which is essentially checks if length of flowfile contents (in attribute) is less than equals to 100, if true, return entire string as is, else return substring up to 100 characters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With