0

Here is my code:

try{
    if(fichadaHecha==false)
        {
            Element fichada = new Element("fichada");
                  //Nº TERMINAL
                  fichada.addContent(new Element("N_Terminal").setText("XX"));
                  //TARJETA
                  fichada.addContent(new Element("Tarjeta").setText(codOperario));
                  //FECHA
                  Date fechaFormatoFecha = new Date( );
                  fichada.addContent(new Element("Fecha").setText(formatoFecha.format(fechaFormatoFecha)));
                  //HORA
                  Date fechaFormatoHora = new Date( );
                  fichada.addContent(new Element("Hora").setText(formatoHora.format(fechaFormatoHora)));
                  //CAUSA
                  fichada.addContent(new Element("Causa").setText("0"));
                  doc.getRootElement().addContent(fichada);
                  XMLOutputter xmlOutput = new XMLOutputter();
                  xmlOutput.setFormat(Format.getPrettyFormat());
                  xmlOutput.output(doc, new FileWriter("C:\\fichadas.xml"));
                  contador=contador+1;
                  //fichadaHecha=true;

              }
                  } catch(IOException io){
                  }

          }
      }, 0L, 5000);

and here is my conf.txt

N_TERMINAL=18

I want to use the value of N_TERMINAL (18) on conf.txt to use it here

fichada.addContent(new Element("N_Terminal").setText("HERE"));

Does someone know how to do this?

ceuben
  • 319
  • 1
  • 4
  • 17
marcss
  • 253
  • 2
  • 14

1 Answers1

2
Properties props = new Properties();
props.load(new FileReader("conf.txt"));
fichada.addContent(new Element("N_Terminal").setText(props.getProperty("N_TERMINAL")));
Roger Gustavsson
  • 1,689
  • 10
  • 20
  • Thanks, but eclipse shows me that filereader cannot be resolved to a type, i need the imports¿ – marcss Apr 23 '15 at 09:46
  • 1
    @marcss `Ctrl + Maj + O` will resolve the import on eclipse ;) – NiziL Apr 23 '15 at 09:48
  • ooooh, thanks, now eclipse shows me that: Multiple markers at this line - Unhandled exception type IOException - Unhandled exception type FileNotFoundException – marcss Apr 23 '15 at 09:49
  • 1
    @marcss You need a `try/catch` block, `Ctrl + Shift + 1` open the quick resolution tools provided by eclipse, it ca – NiziL Apr 23 '15 at 10:53