Class CloudStoragePath
java.lang.Object
com.google.cloud.storage.contrib.nio.CloudStoragePath
A Google Cloud Storage specific implementation of the
java.nio.file.Path interface. An
instance of this class locates an object or a "pseudo-directory" in GCS. This implementation
allows one to use Java's standard file system API to deal with remote objects as if they are
local files.
Example of using java.nio.file.Files to read all lines from a remote object:
Path path = Paths.get(URI.create("gs://bucket/lolcat.csv"));
List<String> lines = Files.readAllLines(path, StandardCharsets.UTF_8);
-
Method Summary
Modifier and TypeMethodDescriptionbucket()Returns the Cloud Storage bucket name being served by this file system.intbooleanbooleanbooleangetName(int index) intgetRoot()inthashCode()booleaniterator()Returns path without extra slashes or.and..and preserves trailing slash.register(WatchService watcher, WatchEvent.Kind<?>... events) ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet.relativize(Path object) resolveSibling(String other) resolveSibling(Path other) booleanstartsWith(String other) booleanstartsWith(Path other) subpath(int beginIndex, int endIndex) Changes relative path to be absolute, usingworkingDirectoryas current dir.toFile()ThrowsUnsupportedOperationExceptionbecause Google Cloud Storage files are not backed by the local file system.toRealPath(LinkOption... options) Returns this path rewritten to the Cloud Storage object name that'd be used to perform i/o.toString()toUri()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
bucket
Returns the Cloud Storage bucket name being served by this file system. -
getFileSystem
- Specified by:
getFileSystemin interfacePath
-
getRoot
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfacePath
-
toAbsolutePath
Changes relative path to be absolute, usingworkingDirectoryas current dir.- Specified by:
toAbsolutePathin interfacePath
-
toRealPath
Returns this path rewritten to the Cloud Storage object name that'd be used to perform i/o.This method makes path
absoluteand removes the prefix slash from the absolute path whenstripPrefixSlashistrue.- Specified by:
toRealPathin interfacePath- Throws:
IllegalArgumentException- if path contains extra slashes or dot-dirs whenpermitEmptyPathComponentsisfalse, or if the resulting path is empty.
-
normalize
Returns path without extra slashes or.and..and preserves trailing slash. -
resolve
-
resolve
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
relativize
- Specified by:
relativizein interfacePath
-
getParent
-
getFileName
- Specified by:
getFileNamein interfacePath
-
subpath
-
getNameCount
public int getNameCount()- Specified by:
getNameCountin interfacePath
-
getName
-
startsWith
- Specified by:
startsWithin interfacePath
-
startsWith
- Specified by:
startsWithin interfacePath
-
endsWith
-
endsWith
-
register
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet. -
register
ThrowsUnsupportedOperationExceptionbecause this feature hasn't been implemented yet. -
toFile
ThrowsUnsupportedOperationExceptionbecause Google Cloud Storage files are not backed by the local file system. -
iterator
-
compareTo
- Specified by:
compareToin interfaceComparable<Path>- Specified by:
compareToin interfacePath
-
equals
-
hashCode
public int hashCode() -
toString
-
toUri
-