Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/352.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中从txt读取变量_Java_Xml_Jdom_Jdom 2 - Fatal编程技术网

在java中从txt读取变量

在java中从txt读取变量,java,xml,jdom,jdom-2,Java,Xml,Jdom,Jdom 2,这是我的密码: try{ if(fichadaHecha==false) { Element fichada = new Element("fichada"); //Nº TERMINAL fichada.addContent(new Element("N_Terminal").setText("XX")); //TARJETA

这是我的密码:

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);
这是我的conf.txt

N_TERMINAL=18
我想使用conf.txt上的N_TERMINAL(18)的值在这里使用它

fichada.addContent(新元素(“N_终端”).setText(“此处”)


有人知道怎么做吗?

谢谢,但eclipse告诉我filereader无法解析为类型,我需要导入?@marcss
Ctrl+Maj+O
将在eclipse上解析导入;)噢,谢谢,现在eclipse向我展示了:这行有多个标记-未处理的异常类型IOException-未处理的异常类型FileNotFoundException@marcss您需要一个
try/catch
块,
Ctrl+Shift+1
打开eclipse提供的快速解析工具,它可以
Properties props = new Properties();
props.load(new FileReader("conf.txt"));
fichada.addContent(new Element("N_Terminal").setText(props.getProperty("N_TERMINAL")));