Ho questo codice:
che mi da questo errore in compilazione nel costrutto try - catch:codice:import java.io.*; import javax.swing.JOptionPane; public class RicercaFile { public static void main( String[] args ) { String path = JOptionPane.showInputDialog( null,"Inserisci il path", "Input path", JOptionPane.INFORMATION_MESSAGE ); if( ( path == null ) ||( path.equals( "" ) ) ) { JOptionPane.showMessageDialog( null,"Dovevi inserire un path", "Errore", JOptionPane.ERROR_MESSAGE ); System.exit( 0 ); } mostra(path); System.exit( 1 ); } public static void mostra(String path) { try { File f = new File( path ); File[] contenuto = f.listFiles(); if(contenuto.length != 0) { for( int i = 0; i < contenuto.length; i++ ) { if( contenuto[i].isDirectory() ) { mostra(contenuto[i].getPath()); } } for( int i = 0; i < contenuto.length; i++ ) { if( contenuto[i].isFile() ) { System.out.println( contenuto[i].getName() ); } } } else { JOptionPane.showMessageDialog( null, path + ": non ha files", "Attenzione", JOptionPane.INFORMATION_MESSAGE ); } } catch(IOException e) { System.out.println("IOException " + e); } } }
Probabilmente è anche semplice la soluzione ma non riesco ad immaginarmela.codice:icercaFile.java [50:1] exception java.io.IOException is never thrown in body of corresponding try statement } catch(IOException e) ^ 1 error Errors compiling RicercaFile.
Grazie

Rispondi quotando