I would like to know how to check if a file exists in the directory or if the name of the file typed in by the user matches what is in the directory and if it dont i out put a certain msg.. I am using FileDialog. That is if the user types in the name of a file it loops through the directory for a file with that name. If no match is found then a message should be printed.
FileDialog fileWindow =
new FileDialog(new Frame(), "Tash & David s File Founder System");
fileWindow.setVisible(true);
if (fileWindow.getFile() != null) {
File fileDirectory = new File(fileWindow.getDirectory());
String[] Directory = fileDirectory.list();
for (; i < Directory.length; i++) {
if(Directory[i].startsWith(fileWindow.getFile())){
System.out.print("yes");
}
}
}
else
JOptionPane.showConfirmDialog(null, "Are you Sure");
}