I'm trying to make a Java software that reads from a rtf file and extract information from it.
The rtf may have different tabulation from each line depending. You can see in the 2 images I posted here. (I can not send more than 2 links, sorry)
Now suppose I have this object:
public class Machine {
private String A = null;
private String B = null;
private String C = null;
private String D = null;
private String E = null;
private String F = null;
}
What I'd like to do is to have 2 entity of this type:
Machine[1]: A=X1, B=null, C=null, D=null, E=Y1, F=Z1
Machine[2]: A=null, B=X2, C=null, D=null, E=Y2, F=Z2
I think that a good solution (in pseudo-code) could be something like this:
while( not EOF ){
Move the cursor to the beginning of the line
while( not the end of the line ){
Move the cursor to the value after a tab
position = Get the absolute position (for example the number we can see on the ruler)
Get the variable associated to the position (if position == 1 => A, if position == 2 => B, ... )
Save the read value in the variable.
}
}
Now, according to me, the most difficult part is to retrieve the position.
Please someone can help me?