java.nio.file.Paths Class in Java Last Updated : 12 Mar, 2021 Comments Improve Suggest changes 1 Likes Like Report java.nio.file.Paths class contains static methods for converting path string or URI into Path. Class declaration : public final class Paths extends ObjectMethods: MethodDescriptionget(String first, String... more) This method converts a path string, or a sequence of strings that when joined form a path string, to a Path. get(URI uri) This method converts the given URI to a Path object. 1. public static Path get(String first, String... more): Returns a Path by converting given strings into a Path. If "more" doesn't specify any strings than "first" is the only string to convert. If "more" specify extra strings then "first" is the initial part of the sequence and the extra strings will be appended to the sequence after "first" separated by "/". Parameters: first - initial part of the Path.more - extra strings to be joined to the Path. Returns: resulting Path Throws: InvalidPathException - if a given string cannot be converted to a Path Java // Java program to demonstrate // java.nio.file.Path.get(String first,String... more) // method import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; public class GFG { public static void main(String[] args) throws IOException { // create object of Path Path path = (Path)Paths.get("/usr", "local", "bin"); // print Path System.out.println(path); } } Output/usr/local/bin 2.public static Path get(URI uri): Returns a Path by converting given Uri into a Path. Parameters: uri - to be converted Returns: resulting Path Throws: IllegalArgumentException - if the parameter of URI is not appropriateFileSystemNotFoundException - if the file system, which is identified by URI does not existSecurityException - if security manager denies access to file system Java // Java program to demonstrate // java.nio.file.Path.get(URI uri) method import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.file.Paths; public class Path { public static void main(String[] args) throws IOException, URISyntaxException { String uribase = "https://www.geeksforgeeks.org/"; // Constructor to create a new URI // by parsing the string URI uri = new URI(uribase); // create object of Path Path path = (Path)Paths.get(uri); // print ParentPath System.out.println(path); } } Output: https://www.geeksforgeeks.org/ Create Quiz Comment A abhinavjain194 Follow 1 Improve A abhinavjain194 Follow 1 Improve Article Tags : Java Java-NIO package Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References7 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers1 min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like