所以我现在一直在使用这个项目,最近我遇到了这个问题。
每次应用程序编译都很好,但是当应用程序启动它时,按下详情按钮时会给我这个:
java.lang.NumberFormatException: For input string: "\ProyectoOUMA\ouma.administracfdi.Reader\dist"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebaseEx(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verifyCodebase(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.deploy.security.DeployManifestChecker.verify(Unknown Source)
at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResourcesHelper(Unknown Source)
at com.sun.javaws.security.JNLPSignedResourcesHelper.checkSignedResources(Unknown Source)
at com.sun.javaws.Launcher.prepareResources(Unknown Source)
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.access$000(Unknown Source)
at com.sun.javaws.Main$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
以下是我正在使用的代码:
`package ouma.administracfdi.reader;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import jxl.read.biff.BiffException;
import jxl.write.WriteException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
public class OumaAdministracfdiReader {
public static ArrayList<DatosCfdi> arraydatoscfdi = new ArrayList<>();
DatosCfdi leerXml(File file, String ruta) throws ParserConfigurationException, SAXException, IOException{
DatosCfdi cfdi = new DatosCfdi();
NodeList list;
Node node;
Element element;
String naturaleza = null;
try {
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
list = (NodeList) documentBuilder.parse(file).getElementsByTagName("cfdi:Comprobante"); //VALIDADA
NodeList sublista, subsublista;
Node subnodo, subsubnodo;
for (int i = 0; i < list.getLength(); i++){
node = list.item(i);
try {
cfdi.setSubt(Double.parseDouble(node.getAttributes().getNamedItem("subTotal").getNodeValue()));
cfdi.setTotal(Double.parseDouble(node.getAttributes().getNamedItem("total").getNodeValue()));
cfdi.setTipo(node.getAttributes().getNamedItem("tipoDeComprobante").getNodeValue());
cfdi.setMotdes(node.getAttributes().getNamedItem("motivoDescuento").getNodeValue());
} catch (NullPointerException | NumberFormatException numex) { }//CATCH
cfdi.setFecha(node.getAttributes().getNamedItem("fecha").getNodeValue());
cfdi.setRuta(ruta);
sublista = node.getChildNodes();
for (int a = 0; a < sublista.getLength(); a++){
subnodo = sublista.item(a);
try {
switch(subnodo.getNodeName()){
case "cfdi:Emisor": cfdi.setRfce(subnodo.getAttributes().getNamedItem("rfc").getNodeValue());
cfdi.setNome(subnodo.getAttributes().getNamedItem("nombre").getNodeValue()); break;
case "cfdi:Receptor": cfdi.setRfcr(subnodo.getAttributes().getNamedItem("rfc").getNodeValue());
cfdi.setNomr(subnodo.getAttributes().getNamedItem("nombre").getNodeValue()); break;
case "cfdi:Impuestos":
try {
cfdi.setImpTra(Double.parseDouble(subnodo.getAttributes().getNamedItem("totalImpuestosTrasladados").getNodeValue()));
cfdi.setImpRet(Double.parseDouble(subnodo.getAttributes().getNamedItem("totalImpuestosRetenidos").getNodeValue()));
} catch (NullPointerException nullex) {}
subsublista = subnodo.getChildNodes();
//System.out.println("Tamaño sublista: " + subsublista.getLength());
for (int e = 0; e < subsublista.getLength(); e++){
// System.out.println("Valor de e: " + e);
subsubnodo = subsublista.item(e);
//System.out.println("NOMBRE DEL SUB SUB NODO: " + subsubnodo.getNodeName());
if (subsubnodo.getNodeName().equalsIgnoreCase("cfdi:Retenciones")){
NodeList ssubsubnodo;
ssubsubnodo = subsubnodo.getChildNodes();
for (int u = 0; u < ssubsubnodo.getLength(); u++){
//System.out.println("Valor de U: " + u);
if (ssubsubnodo.item(u).getNodeName().equalsIgnoreCase("cfdi:Retencion")){
//System.out.println("NOMBRE DEL SSSUBNODO: " + ssubsubnodo.item(u).getNodeName());
//System.out.println(ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue() + " " + ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue());
if (ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue().equalsIgnoreCase("ISR")) {
cfdi.setImpRetIsr(Double.parseDouble(ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue()));}
if (ssubsubnodo.item(u).getAttributes().getNamedItem("impuesto").getNodeValue().equalsIgnoreCase("IVA")) {
cfdi.setImpRetIva(Double.parseDouble(ssubsubnodo.item(u).getAttributes().getNamedItem("importe").getNodeValue()));}
}
}//FOR
}//IF
} break;
case "cfdi:Complemento": subsublista = subnodo.getChildNodes();
for (int e=0; e < subsublista.getLength(); e++){
subsubnodo = subsublista.item(e);
if (subsubnodo.getNodeName().matches("tfd:TimbreFiscalDigital")){
cfdi.setUuid(subsubnodo.getAttributes().getNamedItem("UUID").getNodeValue());}
} break;
default : break;
}} catch(NullPointerException nullex) {}
}
}//FOR
} catch (SAXParseException saxe) {cfdi.setRuta(saxe.getMessage() + " " + ruta);}
return cfdi;}
public void recorrerCarpetas(String ruta, CfdiReader f) throws ParserConfigurationException, SAXException, IOException {
DatosCfdi cfdi = new DatosCfdi();
File folder = new File(ruta);
File[] xmlFiles = folder.listFiles();
String filetype;
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
//NodeList list, listemisor, listreceptor, listtfd;
for (int a = 0; a < xmlFiles.length; a++) {
filetype = Files.probeContentType(xmlFiles[a].toPath());
if (xmlFiles[a].isFile() && filetype.contains("xml") && !(xmlFiles[a].getName().equals(".xml"))){
//System.out.println(xmlFiles[a].getPath() + " " + xmlFiles[a].getName());
System.out.println(xmlFiles[a].getPath());
f.archivosenprocesoText.setText(Integer.toString(a));
f.salidaTextArea.setText(xmlFiles[a].getPath());
cfdi = this.leerXml(xmlFiles[a], ruta + "\\" + xmlFiles[a].getName());
arraydatoscfdi.add(cfdi);
}//IS FILE?
else { if (xmlFiles[a].isDirectory()) {
this.recorrerCarpetas(ruta + "\\"+xmlFiles[a].getName(), f);}}
}
}
public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException, BiffException, WriteException, Exception {
OumaAdministracfdiReader a = new OumaAdministracfdiReader();
//a.ejecuta(args);
}
public void ejecuta(String[] args, CfdiReader f) throws Exception {
OumaAdministracfdiReader lee = new OumaAdministracfdiReader();
GuardarDatosExcelApache aexcel = new GuardarDatosExcelApache();
String carpetaactual, carpetaguardar, nombrearchivo;
carpetaactual = f.directorioTextField.getText();
carpetaguardar = f.directorioguardarText.getText();
nombrearchivo = f.nombrearchivoText.getText();
lee.recorrerCarpetas(carpetaactual, f);
f.archivosenprocesoText.setText(String.valueOf(arraydatoscfdi.size()));
//System.out.println(arraydatoscfdi.size());
aexcel.guardarEnExcel(arraydatoscfdi, nombrearchivo, carpetaguardar);
}
public static final String NEWLINE = "\n";
}`
这是jnlp:
`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<jnlp codebase="file:/C:/ProyectoOUMA/ouma.administracfdi.Reader/dist/" href="launch.jnlp" spec="1.0+">
<information>
<title>ouma.administracfdi.Reader</title>
<vendor>USUARIO</vendor>
<homepage href=""/>
<description>ouma.administracfdi.Reader</description>
<description kind="short">ouma.administracfdi.Reader</description>
<offline-allowed/>
</information>
<update check="background"/>
<security>
<all-permissions/>
</security>
<resources>
<j2se java-vm-args="-Xms2048m" version="1.8+"/>
<jar href="ouma.administracfdi.Reader.jar" main="true"/>
<jar href="lib/poi-ooxml-3.13-20150929.jar"/>
<jar href="lib/poi-3.13-20150929.jar"/>
<jar href="lib/xmlbeans-2.6.0.jar"/>
<jar href="lib/poi-examples-3.13-20150929.jar"/>
<jar href="lib/poi-excelant-3.13-20150929.jar"/>
<jar href="lib/poi-ooxml-schemas-3.13-20150929.jar"/>
<jar href="lib/jxl.jar"/>
<extension href="jnlpcomponent1.jnlp"/>
</resources>
<application-desc main-class="ouma.administracfdi.reader.CfdiReader">
</application-desc>
</jnlp>`
我在NetBeans工作。
感谢您的回答!
答案 0 :(得分:-1)
由于您没有任何代码,我无法肯定地说,但我认为问题是您在某处传递字符串而不是文件。例如,您可能有:
("\ProyectoOUMA\ouma.administracfdi.Reader\dist");
你什么时候应该:
(new File("\ProyectoOUMA\ouma.administracfdi.Reader\dist"));
如果这没有帮助,我很乐意再看看是否能看到你的代码。