Olá Pessoal :D
Tenho o seguinte problema:
Criei um objeto com nome ArqDir. Ele recebe um inteiro e um java.io.File no construtor. Quando eu crio este objeto através do JFileChooser.getSelectedFile() ele retorna um File e manda para o construtor do ArqDir. Até ai beleza! Pego o ArqDir e faço ArqDir.getArqPath.getAbsolutePath. Mas quando eu crio o objeto a partir de uma String, new ArqDir(numero, new File(minhaStringDoPath)) >>> ArqDir.getArqPath.getAbsolutePath() , ocorre nullPointException. Alguém saberia me dizer por que isso ocorre :?:
Segue código.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gui.util;
import java.io.File;
/**
*
* @author juc
*/
public class ArqDir {
private int tipoArq;
private File arqPath;
public ArqDir(Integer tpArq, File path){
super();
this.tipoArq = tpArq;
this.arqPath = arqPath;
System.out.print(path.getAbsolutePath());
}
public int getTipoArq() { return this.tipoArq; }
public File getArqPath() { return this.arqPath; }
public void setTipoArq(int tpArq) { this.tipoArq = tpArq; }
public void setArqPath(File path) { this.arqPath = path; }
}
if (jTF_arqPisCofins.getText() == ""){
listaErro.add(new ErrorMessage( 1,
1,
"O arquivo EFD Pis/Cofins não foi informado!",
"Favor informar um arquivo válido para a EFD Pis/Cofins."));
} else {
arqPisCofins = new ArqDir(EFD_PISCOFINS_FILE, new File(jTF_arqPisCofins.getText()));
}
System.out.println(arqPisCofins.getArqPath().getAbsolutePath());
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at gui.AvalArqSPEDFiscal.validaParametros(AvalArqSPEDFiscal.java:1185)
at gui.AvalArqSPEDFiscal.jB_execAvalActionPerformed(AvalArqSPEDFiscal.java:910)
at gui.AvalArqSPEDFiscal.access$000(AvalArqSPEDFiscal.java:41)
at gui.AvalArqSPEDFiscal$1.actionPerformed(AvalArqSPEDFiscal.java:271)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2478)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)