How to parse text and build object node

Dear All,
I have a text file as following. I have tried with one node to parse it and store the information. But I can not parse when I have put multiple node. Could you please suggestion me or help on this. How can I store information according node by reading this text file.
Thanks in advance .
AUM
  file1.txt
abattoirs
     TNR: 3786
      BT: buildings
      RT: abattoir workers
      RT: meat byproducts
      RT: meat hygiene
      RT: meat inspection
      RT: meat production
      RT: meatworks effluent
      RT: slaughter
      RT: slaughterhouse waste
      RT: slaughtering equipment
abdomen
     TNR: 3792
      BT: body regions
      NT: umbilicus
      RT: abdominal cavity
      RT: belly
      RT: body cavities
      RT: laparotomy
      RT: peritoneum
abdominal cavity
     TNR: 3793
      BT: body cavities
      RT: abdomen
public class TextParser {
    public static String BT;
    public static String RT;
    public static String NT;
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("C:/file1.txt");
        BufferedReader reader = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
        while (true) {
            String line = reader.readLine().trim();
            if (line.startsWith("BT")) {
                String bt[] = line.split(":");
                System.out.println("BT="  +bt[0]);+
+                System.out.println("Value="+  bt[1]);
            } else if (line.startsWith("RT")) {
                String rt[] = line.split(":");
                System.out.println("RT="  +rt[0]);+
+                System.out.println("Value="+  rt[1]);
            } else if (line.startsWith("NT")) {
                String nt[] = line.split(":");
                System.out.println("NT="  +nt[0]);+
+                System.out.println("Value="+  nt[1]);
            } else {
                System.out.println(" this is system");
}

aum1471 wrote:
My problem is storing this large number txt file. I have started but I do not understand how I can create node after reading this files and store information one basis of
node 1
node 2
so on. .. .Your question is still not entirely clear, but it sounds like you're looking for a Map (if you want to access various nodes by arbitrary names) or an array or ArrayList (if you want random access to nodes by index) or a general List (if you want to access nodes sequentially in the order in which you read them) or Set (if you want only one of each node, and don't care about the order).
Google for java collections tutorial and java arrays tutorial.

Similar Messages

  • How to get subject text and Reference Object both Screens at the Header lev

    Dear Experts ,
                    I am getting only Notification Header Screen ( Subject Text, Notification system and User Status) at the Header of Notification and different Tabs under that screen.
                    I want Subject Text and Reference Object screens at header Level so that any screen Tab selected at a time I can see the Subject and Reference Object of the Notification.
                    Pls tell me is there any way so I can Include 2 screens( Subject and Reference Object at the Header Level.)
    With best regards,
    Narendra

    Narendra,
    You can't in the standard system.
    Only the tabs are configurable.
    PeteA

  • Problem while loading texts and authorization objects file in RAR

    Hi all,
           i am getting internet explorer error while loading the texts and authorization objects text files in RAR .actually we uploaded rule file before this,does this step causes any error ?if so how to resolve this error.do i need to remove all rules/risks and then load text and authorization files? is there any shortcut to renove all risks generated in one shot? please reply me soon to resolve this.
    Thanks,
    Joseph.

    Hi Joseph,
    Please make sure to convert both the files in UTF-8 encoding format and then try to upload the files again. This should resolve the issue and if not then please paste the logs here.
    Regards
    Harleen

  • How to extract text of info object

    how to extract text of info object ?
    Example text of project defination from 0PROJECT

    Hi Siri,
    I think you can't display the text element if you display the data in the dso.
    In the dso, you will see only the key part.
    So you don't have to load the infoobject text into the DSO, you just have to load the infoobject.
    In Bex you have the option to see either key,text or both.
    Refet the below thread for details.
    Link: [Loading Master Data Text to DSO.;
    Hope it helps you in clearing your doubt.
    Regards,
    Nikhil Joy

  • I cannot resize the selected text and the object in Illustrator

    I am unable to resize the text and the object with transform tool. It resizes but half of it does not. and not that much i want.

    Ok so if i write some text and all the words are of different sizes and i have to resize it using the transform tool, i cannot resize it unto the size i want. e.g.. i wrote this text "The Big Bold Sale" all the words are of different sizes and are grouped together, so when i resize it using transform tool all these words are resized differently "The big" becomes big, "bold" becomes little smaller and "sale" is not resized.. the image is attached.

  • How to add text and objects (arrows) over a PDF document?

    I am only familiar with Adobe Reader.  Looking for the least expensive Adobe product that would allow me to add text and arrows over an existing PDF document.  Not looking to edit (change) document other than add a "layer" over the original.  Basic stuff I'm sure.  Thanks for your help. 

    If you say so But I read the Original Comments and it doesn't sound like adding comments. When you adding layers as he is describing That is adding content.
    "Not looking to edit (change) document other than add a 'layer' over the original."
    But if you say Commenting then I suppose you are all correct.

  • How to parse XML to Java object... please help really stuck

    Thank you for reading this email...
    If I have a **DTD** like:
    <!ELEMENT person (name, age)>
    <!ATTLIST person
         id ID #REQUIRED
    >
    <!ELEMENT name ((family, given) | (given, family))>
    <!ELEMENT age (#PCDATA)>
    <!ELEMENT family (#PCDATA)>
    <!ELEMENT given (#PCDATA)>
    the **XML** like:
    <person id="a1">
    <name>
         <family> Yoshi </family>
         <given> Samurai </given>
    </name>
    <age> 21 </age>
    </person>
    **** Could you help me to write a simple parser to parse my DTD and XML to Java object, and how can I use those objects... sorry if the problem is too basic, I am a beginner and very stuck... I am very confuse with SAXParserFactory, SAXParser, ParserAdapter and DOM has its own Factory and Parser, so confuse...
    Thank you for your help, Yo

    Hi, Yo,
    Thank you very much for your help. And I Wish you are there...I'm. And I plan to stay - It's sunny and warm here in Honolulu and the waves are up :)
    A bit more question for dear people:
    In the notes, it's mainly focus on JAXB,
    1. Is that mean JAXB is most popular parser for
    parsing XML into Java object? With me, definitely. There are essentially 3 technologies that allow you to parse XML documents:
    1) "Callbacks" (e.g. SAX in JAXP): You write a class that overrides 3 methods that will be called i) whenever the parser encounters a start tag, ii) an end tag, or iii) PCDATA. Drawback: You have to figure out where the heck in the document hierarchy you are when such a callback happens, because the same method is called on EACH start tag and similarly for the end tag and the PCDATA. You have to create the objects and put them into your own data structure - it's very tedious, but you have complete control. (Well, more or less.)
    2) "Tree" (e.g. DOM in JAXP, or it's better cousin JDOM): You call a parser that in one swoop creates an entire hierarchy that corresponds to the XML document. You don't get called on each tag as with SAX, you just get the root of the resulting tree. Drawback: All the nodes in the tree have the same type! You probably want to know which tags are in the document, don't you? Well, you'll have to traverse the tree and ask each node: What tag do you represent? And what are your attributes? (You get only strings in response even though your attributes often represent numbers.) Unless you want to display the tree - that's a nice application, you can do it as a tree model for JTree -, or otherwise don't care about the individual tags, DOM is not of much help, because you have to keep track where in the tree you are while you traverse it.
    3) Enter JAXB (or Castor, or ...): You give it a grammar of the XML documents you want to parse, or "unmarshall" as the fashion dictates to call it. (Actually the name isn't that bad, because "parsing" focuses on the input text while "unmarshalling" focuses on the objects you get, even though I'd reason that it should be marshalling that converts into objects and unmarshalling that converts objects to something else, and not vice versa but that's just my opinion.) The JAXB compiler creates a bunch of source files each with one (or now more) class(es) (and now interfaces) that correspond to the elements/tags of your grammar. (Now "compiler" is a true jevel of a misnomer, try to explain to students that after they run the "compiler", they still need to compile the sources the "compiler" generated with the real Java compiler!). Ok, you've got these sources compiled. Now you call one single method, unmarshall() and as a result you get the root node of the hierarchy that corresponds to the XML document. Sounds like DOM, but it's much better - the objects in the resulting tree don't have all the same type, but their type depends on the tag they represent. E.g if there is the tag <ball-game> then there will be an object of type myPackage.BallGame in your data structure. It gets better, if there is <score> inside <ball-game> and you have an object ballGame (of type BallGame) that you can simply call ballGame.getScore() and you get an object of type myPackage.Score. In other words, the child tags become properties of the parent object. Even better, the attributes become properties, too, so as far as your program is concerned there is no difference whether the property value was originally a tag or an attribute. On top of that, you can tell in your schema that the property has an int value - or another primitive type (that's like that in 1.0, in the early release you'll have to do it in the additional xjs file). So this is a very natural way to explore the data structure of the XML document. Of course there are drawbacks, but they are minor: daunting complexity and, as a consequence, very steep learning curve, documentation that leaves much to reader's phantasy - read trial and error - (the user's guide is too simplicistic and the examples too primitive, e.g. they don't even tell you how to make a schema where a tag has only attributes) and reference manual that has ~200 pages full of technicalities and you have to look with magnifying glas for the really usefull stuff, huge number of generated classes, some of which you may not need at all (and in 1.0 the number has doubled because each class has an accompanying interface), etc., etc. But overall, all that pales compared to the drastically improved efficiency of the programmer's efforts, i.e. your time. The time you'll spend learning the intricacies is well spent, you'll learn it once and then it will shorten your programming time all the time you use it. It's like C and Java, Java is order of magnitude more complex, but you'd probably never be sorry you gave up C.
    Of course the above essay leaves out lots and lots of detail, but I think that it touches the most important points.
    A word about JAXB 1.0 vs. Early Release (EA) version. If you have time, definitively learn 1.0, they are quite different and the main advantage is that the schema combines all the info that you had to formulate in the DTD and in the xjs file when using the EA version. I suggested EA was because you had a DTD already, but in retrospect, you better start from scratch with 1.0. The concepts in 1.0 are here to stay and once your surmounted the learning curve, you'll be glad that you don't have to switch concepts.
    When parser job is done,
    what kind of Java Object we will get? (String,
    InputStream or ...)See above, typically it's an object whose type is defined as a class (and interface in 1.0) within the sources that JABX generates. Or it can be a String or one of the primitive types - you tell the "compiler" in the schema (xjs file in EA) what you want!
    2. If we want to use JAXB, we have to contain a
    XJS-file? Something like:In EA, yes. In 1.0 no - it's all in the schema.
    I am very new to XML, is there any simpler way to get
    around them? It has already take me 4 days to find a
    simple parser which give it XML and DTD, then return
    to me Java objects ... I mean if that kind of parser
    exists....It'll take you probably magnitude longer that that to get really familiar with JAXB, but believe me it's worth it. You'll save countless days if not weeks once you'll start developing serious software with it. How long did it take you to learn Java and it's main APIs? You'll either invest the time learning how to use the software others have written, or you invest it writing it yourself. I'll take the former any time. But it's only my opinion...
    Jan

  • How to set text and background color of current row in a adf table?

    Hi,
    In jdev 11.1.2.3,
    How to set text fond and background color of current row in a adf table?
    I tried to set Background color in table property, but that is not what i want.
    Thanks.

    Hi,
    We almost had the same requirement, but we just needed to color a specific column.
    Here goes the solution to that, you might do the same for your row highlighting
    Changes are required in jsff and one method to be added in backing bean
    1. JSFF :
    <af:column headerText="Amount"
                     id="c4" width="100"
                     inlineStyle="#{backingBeanScope.BackingBean.cellColor}">2. Backing Bean
    //searchResultTableVO is Table's VO
    public String getCellColor() {
          FacesContext ctx = FacesContext.getCurrentInstance();
          ExpressionFactory ef = ctx.getApplication().getExpressionFactory();
          ValueExpression ve = ef.createValueExpression(ctx.getELContext(), "#{row}", FacesCtrlHierNodeBinding.class);
          FacesCtrlHierNodeBinding node = (FacesCtrlHierNodeBinding)ve.getValue(ctx.getELContext());
          Row row = node.getRow();
        if(row.equals(searchResultTableVO.getCurrentRow())){
    //You can add your inline style for font-style too
          return "background-color:Red;";
             return null;
      }Hope this is helpful :)
    Regards,
    Neha..

  • How to load text for Z-objects?

    Hello Experts!!
    I am implementinh HR for BI reports.
    Now in some of the Zobjects created for details like bank details(for acoount number etc) i am getting only the key values from the attribute datasource.
    How to get the releated text values.
    do i need to create a text datasource? How to link the text and attributes , so that we can load text and see it in reporting as well
    Thanks
    Shilpa

    Generally, you dont always need to create a text datasource if it is not relevant. Just uncheck the checkbox "With text" in the InfoObject itself. Otherwise if you need a text datasource, you need to identify the text table in source system or identify the table where the key value (and maybe other attributs) is existing and you can read the text. Then create a generic text datasource (if no standard text datasource is available).
    But your question seems to be, how to get more attribute and text in the same ZObject? Just adding attribut objects you need and match them with the attribut datasource. You can also use a charateristic field here for the text field. The text field will be a attribut of that ZOBJECT and you dont need to create an extra text datasource.

  • How to read text and it's font details (Family and size) using Acrobat plugin?

    Hello,
           I have query about reading PDF, I wanted to extract text and it's font details (Family and size) using Acrobat plugin. How can I achieve that?
    Any suggestions are welcome.
    Thanks
    Rohit Shinde

    Look at the samples in the SDK around PDFEdit and the PDEdit APIs.

  • Can not Group text and shape/object

    I have previously made frequent use of grouping text and objects or images together. But in Keynote 4.0.2 this is not possible (for me at least). I am able to lock multiple images, but the group, mask and alpha buttons are not active when selecting a combination of the two (text and objects). Images or objects can be grouped together. Is this a bug or what ?

    Open a NEW presentation (it should default to the Title and Subtitle slide of the theme)
    Type some text into the Title
    Insert a shape (square)
    Select the shape and the Title
    You should see that you cannot group anything with either the Title or Subtitle object of a slide. If you want to group text to an object, you have to create a new text object. Would this describe your inability to group (ie. limited to when you have Title/Subtitle selected?)

  • How to transport Enqueue and Dequeue Objects / Lock Objects / R3

    Hi Gurus,
    i have created two lock Objects.
    I transported those objects in Q system but the table tab has no objects.
    But in Dev every thing is correct.
    Could you please indicate how i can get the objects correctly transported?
    Thanks

    Easy and best approach is by getting them re transported by using transport of copy request (Type of request)
    1) Get the Transport of copy request created by basis team / urself under your user.
    2) Go to SE10 and highlight the request and click on include objects icon
    3) Later in the pop up window select the radio button which mentions "Include free objects"
    4) Then in the next screen mention the details based on the attributes of the Enque and deque object or else provide the package name and execute and in the next screen choose the concerned enque and deque objects and include them in the request.
    5) Transport the Transport of copy to quality.
    Also, more easiest is.
    Find out the task of the request with with the enque and deque objects were created with (if more than one select all), and then include the tasks in the transport of copy and transport it to next system
    If you are not able to do the above two steps then i think the object is $TMP object, kindly cross check.
    Cheers

  • How to extract text and image information from postscript file

    I want to write a programe,and extract text and image information from postscript file using Java.Is it possible? How to extract ?
    Thank!

    First of all, PostScript is not a "text" file. It can and often does contain binary data. Since PostScript streams often contain nested procedures, unless you process the procedure definitions and can "execute" them, you cannot simply "scan" a file to get what you want. No, I can't talk about this in detail since it is quite complex. But Adobe does have the
    PostScript Language Reference Manual on-line for download at
    . Look that over and you will have a fairly healthy respect as to the task involved.
    - Dov

  • XML StAX - How to extract text and elements?

    Hello,
    I'm using StAX to parse this XML document (heavily reduced):
    <?xml version="1.0" encoding="utf-8"?>
    <html>
      <head>
        <title>Foo</title>
      </head>
      <body>
        <p>loading ...</p>
      </body>
    </html>I need to extract the data between the <body> element i.e "<p>loading...</p>". My problem is that I can only find methods that extracts the text and not the elements. Is there an easy way to do this using the XMLStreamReader instance, or do I have to use another class?
    Thanks

    Thanks for your reply. But does that really mean that I have to create my own method, which will collect both text and elements information in a StringBuffer as I parse through the enclosing element? I just think it is strange that there isn't a convenient method to extract all data (text & elements) between one element.
    Something like this?:
    private void handleBody(XMLStreamReader parser,XMLEventAllocator allocator) throws XMLStreamException {
              StringBuffer body = new StringBuffer();               
              while(true){
                   String value = null;
                   parser.next();               
                   if (parser.getEventType() == XMLStreamConstants.START_ELEMENT){
                        String name = parser.getLocalName();
                        if (!name.equalsIgnoreCase("body")){
                             StartElement startElement = getXMLEvent(allocator,parser).asStartElement();                         
                             value = startElement.toString();
                   else if (parser.getEventType() == XMLStreamConstants.END_ELEMENT){
                        String name = parser.getLocalName();
                        if (name.equalsIgnoreCase("body")){
                             break;
                        else{                         
                             EndElement endElement = getXMLEvent(allocator,parser).asEndElement();                         
                             value = endElement.toString();
                   else if (parser.hasText()){                    
                        value = parser.getText();
                   if (value != null){
                        body.append(value);               
         }

  • How to parse xml and import to execel

    pls let me know how to parse XML file and import all data to execel sheet.

    Hi Mandya,
    This is outside of the normal use case for TestStand. It would be best to use a code module (developed in LabVIEW, C, or any other language) to accomlish this and then call it from a step in TestStand. You can find examples on ActiveX here:
    http://forums.ni.com/t5/NI-TestStand/Controlling-Excel-from-TestStand-with-Activex-Automation/td-p/1...
    I hope this helps.
    Frank L.
    Software Product Manager
    National Instruments

Maybe you are looking for

  • Time Machine showing multiple times in finder

    One of my clients is having an issue where throughout the week the time machine volume will slowly keep adding multiple copys of itself to his finder sidebar. It seems like it is not unmounting after a backup and will clutter the finder sidebar. A re

  • How do I disable my double sided printing?

    I have an HP Office Jet PRO 8600 N911a printer and a MacBook Pro (OSX 10.9.2). I can't seem to disable the double sided printing. I do not have a copy doublesided box to check or uncheck when I use the drop down menu to print.  Can you tell me how to

  • Action Script error:  undefined property

    In the situation below (simplified for this post), I'd like to be able to use "changeTxt.as" for all my components so that I don't have to write a different AS file for each component (40-50 components).  I hoped that by utilizing the switch method (

  • How do I get pictures off my ipod

    I have an older Ipod and I want to get the pictures off of it? I've tried looking at my computer when it's connected but I see nothing in any of the folders. What should I try next?

  • FI & SD Link

    Hello All, Based on the Selection screen criteria i am accessing Data from BSAD (FI, specifically for Document Type DA and RV). If the Document type is 'DA' its a Finance document and all the information can be obtained from BSAD itself. If the Docum