Stay organized with collections
Save and categorize content based on your preferences.
Paths
public
final
class
Paths
extends Object
This class consists exclusively of static methods that return a Path
by converting a path string or URI
.
Summary
Public methods |
static
Path
|
get(URI uri)
Converts the given URI to a Path object.
|
static
Path
|
get(String first, String... more)
Converts a path string, or a sequence of strings that when joined form
a path string, to a Path .
|
Inherited methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait(long timeoutMillis, int nanos)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait(long timeoutMillis)
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted, or until a
certain amount of real time has elapsed.
|
final
void
|
wait()
Causes the current thread to wait until it is awakened, typically
by being notified or interrupted.
|
|
Public methods
get
public static Path get (URI uri)
Converts the given URI to a Path
object.
Implementation Requirements:
Parameters |
uri |
URI : the URI to convert |
Returns |
Path |
the resulting Path |
Throws |
IllegalArgumentException |
if preconditions on the uri parameter do not hold. The
format of the URI is provider specific. |
FileSystemNotFoundException |
The file system, identified by the URI, does not exist and
cannot be created automatically, or the provider identified by
the URI's scheme component is not installed |
SecurityException |
if a security manager is installed and it denies an unspecified
permission to access the file system |
get
public static Path get (String first,
String... more)
Converts a path string, or a sequence of strings that when joined form
a path string, to a Path
.
Implementation Requirements:
Parameters |
first |
String : the path string or initial part of the path string |
more |
String : additional strings to be joined to form the path string |
Returns |
Path |
the resulting Path |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# Paths\n\nAdded in [API level 26](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Methods](#pubmethods) \\| [Inherited Methods](#inhmethods) \n\nPaths\n=====\n\n\n`\npublic\n\nfinal\n\nclass\nPaths\n`\n\n\n`\n\nextends `[Object](/reference/java/lang/Object)`\n\n\n`\n\n`\n\n\n`\n\n|---|---------------------|\n| [java.lang.Object](/reference/java/lang/Object) ||\n| ↳ | java.nio.file.Paths |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nThis class consists exclusively of static methods that return a [Path](/reference/java/nio/file/Path)\nby converting a path string or [URI](/reference/java/net/URI). \n**See also:**\n\n- [Path](/reference/java/nio/file/Path)\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static `[Path](/reference/java/nio/file/Path) | ` `[get](/reference/java/nio/file/Paths#get(java.net.URI))`(`[URI](/reference/java/net/URI)` uri) ` Converts the given URI to a [Path](/reference/java/nio/file/Path) object. |\n| ` static `[Path](/reference/java/nio/file/Path) | ` `[get](/reference/java/nio/file/Paths#get(java.lang.String,%20java.lang.String[]))`(`[String](/reference/java/lang/String)` first, `[String...](/reference/java/lang/String)` more) ` Converts a path string, or a sequence of strings that when joined form a path string, to a `Path`. |\n\n| ### Inherited methods |\n|-----------------------|---|\n| From class ` `[java.lang.Object](/reference/java/lang/Object)` ` |---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](/reference/java/lang/Object) | ` `[clone](/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object. | | ` boolean` | ` `[equals](/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Indicates whether some other object is \"equal to\" this one. | | ` void` | ` `[finalize](/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final `[Class](/reference/java/lang/Class)`\u003c?\u003e` | ` `[getClass](/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this `Object`. | | ` int` | ` `[hashCode](/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object. | | ` final void` | ` `[notify](/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` `[notifyAll](/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor. | | ` `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/Object#toString())`() ` Returns a string representation of the object. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` `[wait](/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||\n\nPublic methods\n--------------\n\n### get\n\nAdded in [API level 26](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static Path get (URI uri)\n```\n\nConverts the given URI to a [Path](/reference/java/nio/file/Path) object.\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- This method simply invokes [* Path.of(URI)](/reference/java/nio/file/Path#of(java.net.URI)) with the given parameter.\n\n| Parameters ||\n|-------|----------------------------------|\n| `uri` | `URI`: the URI to convert \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------|-----------------------------|\n| [Path](/reference/java/nio/file/Path) | the resulting `Path` \u003cbr /\u003e |\n\n| Throws ||\n|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [IllegalArgumentException](/reference/java/lang/IllegalArgumentException) | if preconditions on the `uri` parameter do not hold. The format of the URI is provider specific. |\n| [FileSystemNotFoundException](/reference/java/nio/file/FileSystemNotFoundException) | The file system, identified by the URI, does not exist and cannot be created automatically, or the provider identified by the URI's scheme component is not installed |\n| [SecurityException](/reference/java/lang/SecurityException) | if a security manager is installed and it denies an unspecified permission to access the file system |\n\n**See also:**\n\n- [Path.of(URI)](/reference/java/nio/file/Path#of(java.net.URI)) \n\n### get\n\nAdded in [API level 26](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic static Path get (String first, \n String... more)\n```\n\nConverts a path string, or a sequence of strings that when joined form\na path string, to a `Path`.\n\n\u003cbr /\u003e\n\n##### Implementation Requirements:\n\n- This method simply invokes [Path.of(String, String...)](/reference/java/nio/file/Path#of(java.lang.String,%20java.lang.String[])) with the given parameters.\n\n| Parameters ||\n|---------|--------------------------------------------------------------------------|\n| `first` | `String`: the path string or initial part of the path string \u003cbr /\u003e |\n| `more` | `String`: additional strings to be joined to form the path string \u003cbr /\u003e |\n\n| Returns ||\n|---------------------------------------|-----------------------------|\n| [Path](/reference/java/nio/file/Path) | the resulting `Path` \u003cbr /\u003e |\n\n| Throws ||\n|-----------------------------------------------------------------------|----------------------------------------------------|\n| [InvalidPathException](/reference/java/nio/file/InvalidPathException) | if the path string cannot be converted to a `Path` |\n\n**See also:**\n\n- [FileSystem.getPath(String, String)](/reference/java/nio/file/FileSystem#getPath(java.lang.String,%20java.lang.String[]))\n- [Path.of(String, String)](/reference/java/nio/file/Path#of(java.lang.String,%20java.lang.String[]))"]]