`Hi, We are getting some junk values at the end of a fixed length file. It looks a space but actually its some junk characters.
It looks like � in wordpad.
When i try to remove the blank line using the below code, its not able to remove the junk value and i get error. Can some one help.
Also when i try to count the number of lines in the file, i get the count including the blank line as there is some junk at the end which the groovy script is not able to remove using the below script.'
Groovy Script code to remove blank line.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
def Message processData(Message message) {
def body = message.getBody(java.lang.String);
def BodyList = body.readLines();
def count = BodyList.size();
messageLog.setStringProperty("count",''+ count);
def output = [];
for (i in 0..<BodyList.size())
{
def line = BodyList[i];
if (!(line.trim() == "" || line.length() <= 0 || line.trim().equals('')))
{
output << line;
}
}
message.setBody( output.join(System.getProperty("line.separator")))
messageLog.setStringProperty("output.size",''+ output.size());
return message;
}