Spec-Zone .ru
спецификации, руководства, описания, API
Please note that the specifications and other information contained herein are not final and are subject to change. The information is being made available to you solely for purpose of evaluation.

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

java.nio.file
Class Paths

java.lang.Object
  extended by java.nio.file.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.

Since:
1.7

Method Summary
Modifier and Type Method and Description
static Path get(String path)
          Constructs a Path by converting the given path string.
static Path get(URI uri)
          Converts the given URI to a Path object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static Path get(String path)
Constructs a Path by converting the given path string.

The Path is obtained by invoking the getPath method of the default FileSystem.

Note that while this method is very convenient, using it will imply an assumed reference to the default FileSystem and limit the utility of the calling code. Hence it should not be used in library code intended for flexible reuse. A more flexible alternative is to use an existing Path instance as an anchor, such as:

     Path dir = ...
     Path path = dir.resolve("file");
 

Parameters:
path - the path string to convert
Returns:
the resulting Path
Throws:
InvalidPathException - if the path string cannot be converted to a Path
See Also:
FileSystem.getPath(java.lang.String)

get

public static Path get(URI uri)
Converts the given URI to a Path object.

This method iterates over the installed providers to locate the provider that is identified by the URI scheme of the given URI. URI schemes are compared without regard to case. If the provider is found then its getPath method is invoked to convert the URI.

In the case of the default provider, identified by the URI scheme "file", the given URI has a non-empty path component, and undefined query and fragment components. Whether the authority component may be present is platform specific. The returned Path is associated with the default file system.

The default provider provides a similar round-trip guarantee to the File class. For a given Path p it is guaranteed that

Paths.get(p.toUri()).equals( p.toAbsolutePath())
so long as the original Path, the URI, and the new Path are all created in (possibly different invocations of) the same Java virtual machine. Whether other providers make any guarantees is provider specific and therefore unspecified.

Parameters:
uri - the URI to convert
Returns:
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

Java™ Platform
Standard Ed. 7

DRAFT ea-b118

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2010, Oracle Corporation. All rights reserved.
DRAFT ea-b118

Scripting on this page tracks web page traffic, but does not change the content in any way.