0

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)

Header Tabulation:

Line 1 Tabulation

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?

Has QUIT--Anony-Mousse
  • 76,138
  • 12
  • 138
  • 194
Timmy
  • 693
  • 2
  • 8
  • 26
  • you should provide your current solution first, what seems to be wrong with it and work your way up from there – Emre Türkiş Jan 06 '16 at 19:35
  • I can write only pseudo code because I've no idea on how to read a RTF, in fact that my question, just let me know what can I do to help you. – Timmy Jan 06 '16 at 20:26

0 Answers0