Skip to content

Instantly share code, notes, and snippets.

@victorvaz
Created October 30, 2015 02:31
Show Gist options
  • Save victorvaz/1da607d7b9e397ed8a78 to your computer and use it in GitHub Desktop.
Save victorvaz/1da607d7b9e397ed8a78 to your computer and use it in GitHub Desktop.
Verificar a existência de um arquivo com java
import java.io.File;
public class VerificaExistenciaArquivo
{
public static void main (String [] args)
{
// Cria uma instancia da classe File:
File arquivo = new File("C://arquivo.pdf");
// Usa a função exists para verificar se o arquivo existe ou não:
if (arquivo.exists())
System.out.println("O arquivo existe!");
else
System.out.println("O arquivo não existe!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment