Pessoal, estou usando o fonte acima que copiei do tutorial daqui, porém mesmo eu colocando a biblioteca java.io.* ocorre o seguinte erro:
Exception in thread “AWT-EventQueue-0” java.lang.Error: Unresolved compilation problem:
Type mismatch: cannot convert from String to boolean
at gui.Tela_Pesq.getBPesquisar(Tela_Pesq.java:83)
at gui.Tela_Pesq.getJContentPane(Tela_Pesq.java:49)
at gui.Tela_Pesq.getJFrame(Tela_Pesq.java:30)
at gui.Tela_Principal$2.actionPerformed(Tela_Principal.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Colocando o que me falou piorou a situação veja o erro:
Exception in thread “AWT-EventQueue-0” java.lang.Error: Unresolved compilation problems:
Unhandled exception type FileNotFoundException
Unhandled exception type IOException
Unhandled exception type IOException
Unhandled exception type IOException
at gui.Tela_Pesq.getBPesquisar(Tela_Pesq.java:79)
at gui.Tela_Pesq.getJContentPane(Tela_Pesq.java:49)
at gui.Tela_Pesq.getJFrame(Tela_Pesq.java:30)
at gui.Tela_Principal$2.actionPerformed(Tela_Principal.java:100)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
public class asd {
public static void main(String args[]){
File fl = new File(“C:/arquivo.txt”);
BufferedReader leitor=null;
FileReader reader=null;
try {
reader = new FileReader(fl);
leitor = new BufferedReader(reader);
String linha = null;
while((linha = leitor.readLine())!=null) {
System.out.println("Linha: " + linha);
}
} catch (FileNotFoundException e) {//caso nao encontre o arquivo ele entra neste bloco
try {
System.out.println("Foi criado um novo arquivo!");
fl.createNewFile();
} catch (IOException e1) {
e1.printStackTrace();
}
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
leitor.close();
reader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Mesmo assim, já havia tentado mudar…
O Tanto de vezes que clico neste botão é o tanto que aparece “Vou entrar no While” mas nunca entra…
E o arquivo existe bonitinho no C:\ com dados dele normal.