Using Java.nio.file.Path and Paths class
when comparing 2 paths using the equals() method in java "nio.2", one thing to know 4Sure is that, it does not affect the file System, so, therefore, the compared paths are not required to exist. #Very Funny right? See the below sample code snippet
--------------------------------------
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.lang.System.out;
public class OcpPrepare {
public static void main(String[] args) {
Path firstPath = Paths.get("c:\\users\\Book1.txt");
Path secondPath = Paths.get("c:\\users\\Book2.txt");
if (firstPath.equals(secondPath))
{
out.println("Same Path");
}
else
{
out.println("Not Same Path");
}
}
}
when comparing 2 paths using the equals() method in java "nio.2", one thing to know 4Sure is that, it does not affect the file System, so, therefore, the compared paths are not required to exist. #Very Funny right? See the below sample code snippet
--------------------------------------
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.lang.System.out;
public class OcpPrepare {
public static void main(String[] args) {
Path firstPath = Paths.get("c:\\users\\Book1.txt");
Path secondPath = Paths.get("c:\\users\\Book2.txt");
if (firstPath.equals(secondPath))
{
out.println("Same Path");
}
else
{
out.println("Not Same Path");
}
}
}
No comments:
Post a Comment