# Class CloudStoragePath (0.133.0)

0.133.0 (latest) 0.131.0 0.128.13 0.127.38 0.126.19 0.125.0 0.124.21 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](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> CloudStoragePath

## Implements

[Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html)

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)

## Methods

### bucket()

    public String bucket()

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

### compareTo(Path other)

    public int compareTo(Path other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### endsWith(String other)

    public boolean endsWith(String other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### endsWith(Path other)

    public boolean endsWith(Path other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### equals(Object other)

    public boolean equals(Object other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)

### getFileName()

    public CloudStoragePath getFileName()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### getFileSystem()

    public CloudStorageFileSystem getFileSystem()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystem` |   |

### getName(int index)

    public CloudStoragePath getName(int index)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `index` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### getNameCount()

    public int getNameCount()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### getParent()

    public CloudStoragePath getParent()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### getRoot()

    public CloudStoragePath getRoot()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### hashCode()

    public int hashCode()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

**Overrides** [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)

### isAbsolute()

    public boolean isAbsolute()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### iterator()

    public Iterator<Path> iterator()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Iterator.html<https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html>` |   |

### normalize()

    public CloudStoragePath normalize()

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

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

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

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

Throws [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because this feature hasn't been implemented yet.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `watcher` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchService.html` |
| `events` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchEvent/Kind.html<?>[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchKey.html` |   |

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

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

Throws [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because this feature hasn't been implemented yet.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `watcher` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchService.html` |
| `events` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchEvent/Kind.html<?>[]` |
| `modifiers` | `java.nio.file.WatchEvent.Modifier[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchKey.html` |   |

### relativize(Path object)

    public CloudStoragePath relativize(Path object)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `object` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### resolve(String other)

    public CloudStoragePath resolve(String other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### resolve(Path object)

    public CloudStoragePath resolve(Path object)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `object` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### resolveSibling(String other)

    public CloudStoragePath resolveSibling(String other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### resolveSibling(Path other)

    public CloudStoragePath resolveSibling(Path other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### startsWith(String other)

    public boolean startsWith(String other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### startsWith(Path other)

    public boolean startsWith(Path other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |   |

### subpath(int beginIndex, int endIndex)

    public CloudStoragePath subpath(int beginIndex, int endIndex)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `beginIndex` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |
| `endIndex` | `https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### toAbsolutePath()

    public CloudStoragePath toAbsolutePath()

Changes relative path to be absolute, using [workingDirectory](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageConfiguration#com_google_cloud_storage_contrib_nio_CloudStorageConfiguration_workingDirectory__) as current dir.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### toFile()

    public File toFile()

Throws [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because Google Cloud Storage files are not backed
by the local file system.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/File.html` |   |

### 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](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath#com_google_cloud_storage_contrib_nio_CloudStoragePath_toAbsolutePath__) and removes the prefix slash from
the absolute path when [stripPrefixSlash](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageConfiguration#com_google_cloud_storage_contrib_nio_CloudStorageConfiguration_stripPrefixSlash__) is
`true`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `options` | `java.nio.file.LinkOption[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath` |   |

### toString()

    public String toString()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |   |

**Overrides** [Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)

### toUri()

    public URI toUri()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/net/URI.html` |   |