Excluir file do diretorio

0 respostas
danilorangelmg

Bom dia!

eu preciso excluir alguns files que estao em um diretorio mais não estou conseguindo utilizo a função abaixo para copiar os arquivos para o diretorio mais não consigo excluir os arquivos de la e nem deletar o diretorio.

private static void copyFile(File source, File destination) throws IOException {  
	     if (destination.exists())  
	         destination.delete();  
	  
	     FileChannel sourceChannel = null;  
	     FileChannel destinationChannel = null;  
	  
	     try {  
	         sourceChannel = new FileInputStream(source).getChannel();  
	         destinationChannel = new FileOutputStream(destination).getChannel();  
	         sourceChannel.transferTo(0, sourceChannel.size(),  
	                 destinationChannel);  
	     } finally {  
	         if (sourceChannel != null && sourceChannel.isOpen())  
	             sourceChannel.close();  
	         if (destinationChannel != null && destinationChannel.isOpen())  
	             destinationChannel.close();  
	    }  
	}

alguem sabe de alguma forma de fazer isso?

Criado 19 de dezembro de 2012
Respostas 0
Participantes 1