Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: how to parse structured txt

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default how to parse structured txt

    hi, guys.
    I need to parse a text structured as shown below.

    I'm not expert on parsing text, can someone give me an advice for learn how to parse a text like this?

    / ______________________________________________________________________________
    / MODEL INFORMATION
     
       ModelName            "modelloTestValidazione"
       Title                ""
       Project              ""
       Author               ""
       Reference            ""
       Comments             ""
     
    / ______________________________________________________________________________
    / UNITS
     
       LengthUnit           m
       MassUnit             T
       EnergyUnit           J
       PressureUnit         MPa
       ForceUnit            N
       TemperatureUnit      C
     
    / ______________________________________________________________________________
    / GROUP DEFINITIONS
     
       Group                    1    16711680   "\\Model"
     
    / ______________________________________________________________________________
    / FREEDOM CASE DEFINITIONS
     
       FreedomCase              1       0       1   "Freedom Case 1"
     
     
    / ______________________________________________________________________________
    / LOAD CASE DEFINITIONS
     
       LoadCase                 1       0   "Load Case 1"
         LCInclude              3 
     
     
    / ______________________________________________________________________________
    / COORDINATE SYSTEM DEFINITIONS
     
       CoordSys                 1   "Global XYZ"  GlobalXYZ
     
     
    / ______________________________________________________________________________
    / NODE COORDINATES
     
       Node                     1     0.00000000000000E+0      0.00000000000000E+0      0.00000000000000E+0  
       Node                     2     1.00000000000000E+2      0.00000000000000E+0      0.00000000000000E+0  
       Node                     3     0.00000000000000E+0      1.00000000000000E+2      0.00000000000000E+0  
       Node                     4     0.00000000000000E+0      0.00000000000000E+0      1.00000000000000E+2  
       Node                     5     0.00000000000000E+0      0.00000000000000E+0     -1.00000000000000E+2  
       Node                     6     1.00000000000000E+2      0.00000000000000E+0     -1.00000000000000E+2  
       Node                     7     0.00000000000000E+0      1.00000000000000E+2     -1.00000000000000E+2  
     
    / ______________________________________________________________________________
    / BEAM ELEMENTS
     
       Beam                     1       1       1       1       3 
       Beam                     2       1       1       1       2 
       Beam                     3       1       1       1       4 
       Beam                     4       1       1       3       4 
       Beam                     5       1       1       2       4 
       Beam                     6       1       1       1       5 
       Beam                     7       1       1       2       6 
       Beam                     8       1       1       3       7 
     
    / ______________________________________________________________________________
    / NODE RESTRAINTS (ROTATION AS RADIAN)
    / Freedom Case 1
       NdFreedom                1       5       1       DX  DY  DZ  RX  RY  RZ
       NdFreedom                1       6       1       DX  DY  DZ  RX  RY  RZ
       NdFreedom                1       7       1       DX  DY  DZ  RX  RY  RZ
     
    / ______________________________________________________________________________
    / NODE FORCES
    / Load Case 1
       NdForce                  1       4     5.00000000000000E+1      5.00000000000000E+1      0.00000000000000E+0  
     
    / ______________________________________________________________________________
    / BEAM PROPERTIES
     
       BeamProp                 1   "Beam Property 1"
         MaterialName       "Unknown material - Modified"
         Modulus              1.00000000000000E+3  
         Poisson              2.00000000000000E-1  
         UsePoisson         TRUE
         Area                 1.00000000000000E+0  
         MomentI11            8.33333333333300E-2  
         MomentI22            8.33333333333300E-2  
         MomentJ              1.40666666666700E-1  
         SectionType        SolidRect
           B                  1.00000000000000E+0  
           D                  1.00000000000000E+0  
         NonLinType         Elasticplastic
         Hardening          Isotropic


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: how to parse structured txt

    The main tools for parsing a String are the methods in the String class. See the split() method for example.
    Also the StringTokenizer class can be useful in some cases.
    Also see the Double and Integer classes for parse methods to convert Strings to numeric values.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    tuocuggino (April 30th, 2014)

Similar Threads

  1. Replies: 0
    Last Post: November 13th, 2012, 07:02 AM
  2. Structured Program
    By CarlZabel in forum Java Theory & Questions
    Replies: 0
    Last Post: October 23rd, 2011, 12:00 AM
  3. enum, value of: Why is this code line structured the way it is?
    By SPACE MONKEY in forum Java Theory & Questions
    Replies: 5
    Last Post: March 28th, 2011, 09:15 AM
  4. [SOLVED] parse txt file
    By maliv in forum File I/O & Other I/O Streams
    Replies: 16
    Last Post: November 17th, 2010, 03:54 PM
  5. Structured Properties File?
    By moka in forum Java Theory & Questions
    Replies: 7
    Last Post: October 19th, 2010, 11:14 AM