It reads the file’s content:
public static String stringFromFile(IContext context, FileDocument source, Charset charset) throws IOException {
if (source == null) {
return null;
}
try (InputStream f = Core.getFileDocumentContent(context, source.getMendixObject())) {
return IOUtils.toString(f, charset);
}
}
Here the description from the Mendix Runtime API docs:
getFileDocumentContent
public static java.io.InputStream getFileDocumentContent(IContext context, IMendixObject fileDocument)
Returns contents of a file document as an input stream. The returned stream must be closed when it is not needed anymore. No security checks will be performed.
Parameters:
context
- the context
fileDocument
- the file document from which the contents will be returned
Returns:
the input stream of the file content of the given file document
Hi Tjark,
The action will write the string into a file.
As described in the documentation of the action: “Stores a string into the provided FileDocument, using the specified encoding. Note that destination will be committed”. This can’t be used to compare, because mendix will validate the objects, instead of the content of the file.
StringFromFile, “Reads the contents form the provided file document, using the specified encoding, and returns it as string”.
Using the last option you could compare if the two strings are the same.