Hi, everybody! I'm a real newbie to Java programming and I'm sure I've come to the right place for help. Anyways....I have an assignment that reads like so:
Create two files using any word processing program or text editor. Write an application that determines whether the two files are located in the same folder. Save the file as SameFolder. java.
I'm assuming that I need to construct some sort of IF statement utilizing the public boolean exists() method. But whenever I try to use that method or the isDirectory() method the program won't compile and I get a "cannot find symbol" error right at the exists() and isDirectory() methods. Here's what I have so far:
import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class FileTest
{
public static void main(String[] args)
{
Path path = Paths.get("C:\\Program Files\\Java\\FirstFile.txt");
Path bPath = Paths.get("C:\\Program Files\\Java\\SecondFile.txt");
if(Path.exists(Path path) && Path.exists(Path bPath)
{
System.out.println("Files exist in same folder");
}
}
}
Please note that I have to use the new Paths class. Statements like "File bPath = new File(file1)" cannot be used. Thanks in advance