Class CloudStoragePath (0.123.28)

public final class CloudStoragePath implements Path

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);
 

Inheritance

Object > CloudStoragePath

Implements

Path

Methods

bucket()

public String bucket()

Returns the Cloud Storage bucket name being served by this file system.

Returns
TypeDescription
String

compareTo(Path other)

public int compareTo(Path other)
Parameter
NameDescription
otherPath
Returns
TypeDescription
int

endsWith(String other)

public boolean endsWith(String other)
Parameter
NameDescription
otherString
Returns
TypeDescription
boolean

endsWith(Path other)

public boolean endsWith(Path other)
Parameter
NameDescription
otherPath
Returns
TypeDescription
boolean

equals(Object other)

public boolean equals(Object other)
Parameter
NameDescription
otherObject
Returns
TypeDescription
boolean
Overrides

getFileName()

public CloudStoragePath getFileName()
Returns
TypeDescription
CloudStoragePath

getFileSystem()

public CloudStorageFileSystem getFileSystem()
Returns
TypeDescription
CloudStorageFileSystem

getName(int index)

public CloudStoragePath getName(int index)
Parameter
NameDescription
indexint
Returns
TypeDescription
CloudStoragePath

getNameCount()

public int getNameCount()
Returns
TypeDescription
int

getParent()

public CloudStoragePath getParent()
Returns
TypeDescription
CloudStoragePath

getRoot()

public CloudStoragePath getRoot()
Returns
TypeDescription
CloudStoragePath

hashCode()

public int hashCode()
Returns
TypeDescription
int
Overrides

isAbsolute()

public boolean isAbsolute()
Returns
TypeDescription
boolean

iterator()

public Iterator<Path> iterator()
Returns
TypeDescription
Iterator<Path>

normalize()

public CloudStoragePath normalize()

Returns path without extra slashes or . and .. and preserves trailing slash.

Returns
TypeDescription
CloudStoragePath

register(WatchService watcher, WatchEvent.Kind<?>[] events)

public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events)

Throws UnsupportedOperationException because this feature hasn't been implemented yet.

Parameters
NameDescription
watcherWatchService
eventsKind<?>[]
Returns
TypeDescription
WatchKey

register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier[] modifiers)

public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier[] modifiers)

Throws UnsupportedOperationException because this feature hasn't been implemented yet.

Parameters
NameDescription
watcherWatchService
eventsKind<?>[]
modifiersjava.nio.file.WatchEvent.Modifier[]
Returns
TypeDescription
WatchKey

relativize(Path object)

public CloudStoragePath relativize(Path object)
Parameter
NameDescription
objectPath
Returns
TypeDescription
CloudStoragePath

resolve(String other)

public CloudStoragePath resolve(String other)
Parameter
NameDescription
otherString
Returns
TypeDescription
CloudStoragePath

resolve(Path object)

public CloudStoragePath resolve(Path object)
Parameter
NameDescription
objectPath
Returns
TypeDescription
CloudStoragePath

resolveSibling(String other)

public CloudStoragePath resolveSibling(String other)
Parameter
NameDescription
otherString
Returns
TypeDescription
CloudStoragePath

resolveSibling(Path other)

public CloudStoragePath resolveSibling(Path other)
Parameter
NameDescription
otherPath
Returns
TypeDescription
CloudStoragePath

startsWith(String other)

public boolean startsWith(String other)
Parameter
NameDescription
otherString
Returns
TypeDescription
boolean

startsWith(Path other)

public boolean startsWith(Path other)
Parameter
NameDescription
otherPath
Returns
TypeDescription
boolean

subpath(int beginIndex, int endIndex)

public CloudStoragePath subpath(int beginIndex, int endIndex)
Parameters
NameDescription
beginIndexint
endIndexint
Returns
TypeDescription
CloudStoragePath

toAbsolutePath()

public CloudStoragePath toAbsolutePath()

Changes relative path to be absolute, using workingDirectory as current dir.

Returns
TypeDescription
CloudStoragePath

toFile()

public File toFile()

Throws UnsupportedOperationException because Google Cloud Storage files are not backed by the local file system.

Returns
TypeDescription
File

toRealPath(LinkOption[] options)

public CloudStoragePath toRealPath(LinkOption[] options)

Returns this path rewritten to the Cloud Storage object name that'd be used to perform i/o.

This method makes path absolute and removes the prefix slash from the absolute path when stripPrefixSlash is true.

Parameter
NameDescription
optionsjava.nio.file.LinkOption[]
Returns
TypeDescription
CloudStoragePath

toString()

public String toString()
Returns
TypeDescription
String
Overrides

toUri()

public URI toUri()
Returns
TypeDescription
URI