< prev index next >

src/java.base/share/classes/java/nio/file/Paths.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 31,40 **** --- 31,41 ---- /** * This class consists exclusively of static methods that return a {@link Path} * by converting a path string or {@link URI}. * * @since 1.7 + * @see Path */ public final class Paths { private Paths() { }
*** 66,75 **** --- 67,80 ---- * <pre> * Path dir = ... * Path path = dir.resolve("file"); * </pre> * + * @implSpec + * This method simply invokes {@link Path#get(String,String...) + * Path.get(String, String...)} with the given parameters. + * * @param first * the path string or initial part of the path string * @param more * additional strings to be joined to form the path string *
*** 77,89 **** * * @throws InvalidPathException * if the path string cannot be converted to a {@code Path} * * @see FileSystem#getPath */ public static Path get(String first, String... more) { ! return FileSystems.getDefault().getPath(first, more); } /** * Converts the given URI to a {@link Path} object. * --- 82,95 ---- * * @throws InvalidPathException * if the path string cannot be converted to a {@code Path} * * @see FileSystem#getPath + * @see Path#get(String,String...) */ public static Path get(String first, String... more) { ! return Path.get(first, more); } /** * Converts the given URI to a {@link Path} object. *
*** 110,119 **** --- 116,129 ---- * so long as the original {@code Path}, the {@code URI}, and the new {@code * 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. * + * @implSpec + * <p> This method simply invokes {@link Path#get(URI) + * Path.get(URI)} with the given parameter. + * * @param uri * the URI to convert * * @return the resulting {@code Path} *
*** 125,149 **** * cannot be created automatically, or the provider identified by * the URI's scheme component is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission to access the file system */ public static Path get(URI uri) { ! String scheme = uri.getScheme(); ! if (scheme == null) ! throw new IllegalArgumentException("Missing scheme"); ! ! // check for default provider to avoid loading of installed providers ! if (scheme.equalsIgnoreCase("file")) ! return FileSystems.getDefault().provider().getPath(uri); ! ! // try to find provider ! for (FileSystemProvider provider: FileSystemProvider.installedProviders()) { ! if (provider.getScheme().equalsIgnoreCase(scheme)) { ! return provider.getPath(uri); ! } ! } ! ! throw new FileSystemNotFoundException("Provider \"" + scheme + "\" not installed"); } } --- 135,146 ---- * cannot be created automatically, or the provider identified by * the URI's scheme component is not installed * @throws SecurityException * if a security manager is installed and it denies an unspecified * permission to access the file system + * + * @see Path#get(URI) */ public static Path get(URI uri) { ! return Path.get(uri); } }
< prev index next >