Reading a line from file

0
Is it possible to read a line (500 words in one line) from text file in mendix. A file can have multiple line. I want to read a first line and want to set to one object. Then read second line and set to another object and so on.
asked
2 answers
1

It would use some string manupulation but it would be doable. From the file retrieve the whole text as string in a microflow. Create a counter. Use the find to find the first space (see https://world.mendix.com/display/refguide5/String+function+calls for some examples). Use the substring to split the string up and raise the counter. When you reach 500 take the original string and remove from this the substring of the result. You then have your first 500 word line.

It could be simpeler when there is a carriage return on the end of the 500 words. Then you filter on that for the string manipulation.

Regards,

Ronald

answered
1

You could try something like this

InputStream fstream = Core.getFileDocumentContent(getContext(), file.getMendixObject());
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
while ((strLine = br.readLine()) != null)   {do your create object here}

the file mentioned here is as proxy object that is a specialization of System.filedocument

answered