Thank you so much! Giving it a integer parameter does work
PHP Code:
System.out.println("File name is " + filePath.getName(0));
another errors that might be related to nio class
PHP Code:
import java.nio.file.*;
import static java.nio.file.AccessMode.*;
import java.io.IOException;
public class PathDemo3
{
public static void main(String[] args)
{
Path filePath =
Paths.get("C:\\Java\\Chapter.13\\Data.txt");
System.out.println("Path is " + filePath.toString());
try
{
filePath.checkAccess(READ, EXECUTE);
System.out.println("File can be read and executed");
}
catch(IOException e)
{
System.out.println("File cannot be used for this application");
}
}
}
and
PHP Code:
import java.nio.file.*;
import java.io.IOException;
public class PathDemo4
{
public static void main(String[] args)
{
Path filePath =
Paths.get("C:\\Java\\Chapter.13\\Data.txt");
try
{
filePath.delete();
System.out.println("File or directory is deleted");
}
catch (NoSuchFileException e)
{
System.out.println("No such file or directory");
}
catch (DirectoryNotEmptyException e)
{
System.out.println("Directory is not empty");
}
catch (IOException e)
{
System.out.println("No permission to delete");
}
}
}
return
PHP Code:
PathDemo3.java:13: error: cannot find symbol
filePath.checkAccess(READ, EXECUTE);
^
symbol: method checkAccess(AccessMode,AccessMode)
location: variable filePath of type Path
1 error
and
PHP Code:
PathDemo4.java:11: error: cannot find symbol
filePath.delete();
^
symbol: method delete()
location: variable filePath of type Path
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
it sure looks like I am missing an include, but the only thing that is confusing that those two programs are in my "Java Programming by Joyce Farrell. 6th edition" textbook and according to author should compile without an error.