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:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class CloudStoragePath (0.128.2)\n\nVersion latestkeyboard_arrow_down\n\n- [0.128.2 (latest)](/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.128.1](/java/docs/reference/google-cloud-nio/0.128.1/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.127.38](/java/docs/reference/google-cloud-nio/0.127.38/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.126.19](/java/docs/reference/google-cloud-nio/0.126.19/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.125.0](/java/docs/reference/google-cloud-nio/0.125.0/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.124.21](/java/docs/reference/google-cloud-nio/0.124.21/com.google.cloud.storage.contrib.nio.CloudStoragePath)\n- [0.123.28](/java/docs/reference/google-cloud-nio/0.123.28/com.google.cloud.storage.contrib.nio.CloudStoragePath) \n\n public final class CloudStoragePath implements Path\n\nA Google Cloud Storage specific implementation of the `java.nio.file.Path` interface. An\ninstance of this class locates an object or a \"pseudo-directory\" in GCS. This implementation\nallows one to use Java's standard file system API to deal with remote objects as if they are\nlocal files.\n\nExample of using `java.nio.file.Files` to read all lines from a remote object: \n\n\n Path path = Paths.get(URI.create(\"gs://bucket/lolcat.csv\"));\n List\u003cString\u003e lines = Files.readAllLines(path, StandardCharsets.UTF_8);\n \nInheritance\n-----------\n\n[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e CloudStoragePath \n\nImplements\n----------\n\n[Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nMethods\n-------\n\n### bucket()\n\n public String bucket()\n\nReturns the Cloud Storage bucket name being served by this file system.\n\n### compareTo(Path other)\n\n public int compareTo(Path other)\n\n### endsWith(String other)\n\n public boolean endsWith(String other)\n\n### endsWith(Path other)\n\n public boolean endsWith(Path other)\n\n### equals(Object other)\n\n public boolean equals(Object other)\n\n**Overrides** \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-)\n\n### getFileName()\n\n public CloudStoragePath getFileName()\n\n### getFileSystem()\n\n public CloudStorageFileSystem getFileSystem()\n\n### getName(int index)\n\n public CloudStoragePath getName(int index)\n\n### getNameCount()\n\n public int getNameCount()\n\n### getParent()\n\n public CloudStoragePath getParent()\n\n### getRoot()\n\n public CloudStoragePath getRoot()\n\n### hashCode()\n\n public int hashCode()\n\n**Overrides** \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--)\n\n### isAbsolute()\n\n public boolean isAbsolute()\n\n### iterator()\n\n public Iterator\u003cPath\u003e iterator()\n\n### normalize()\n\n public CloudStoragePath normalize()\n\nReturns path without extra slashes or `.` and `..` and preserves trailing slash.\n\n### register(WatchService watcher, WatchEvent.Kind\\\u003c?\\\u003e\\[\\] events)\n\n public WatchKey register(WatchService watcher, WatchEvent.Kind\u003c?\u003e[] events)\n\nThrows [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because this feature hasn't been implemented yet.\n\n### register(WatchService watcher, WatchEvent.Kind\\\u003c?\\\u003e\\[\\] events, WatchEvent.Modifier\\[\\] modifiers)\n\n public WatchKey register(WatchService watcher, WatchEvent.Kind\u003c?\u003e[] events, WatchEvent.Modifier[] modifiers)\n\nThrows [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because this feature hasn't been implemented yet.\n\n### relativize(Path object)\n\n public CloudStoragePath relativize(Path object)\n\n### resolve(String other)\n\n public CloudStoragePath resolve(String other)\n\n### resolve(Path object)\n\n public CloudStoragePath resolve(Path object)\n\n### resolveSibling(String other)\n\n public CloudStoragePath resolveSibling(String other)\n\n### resolveSibling(Path other)\n\n public CloudStoragePath resolveSibling(Path other)\n\n### startsWith(String other)\n\n public boolean startsWith(String other)\n\n### startsWith(Path other)\n\n public boolean startsWith(Path other)\n\n### subpath(int beginIndex, int endIndex)\n\n public CloudStoragePath subpath(int beginIndex, int endIndex)\n\n### toAbsolutePath()\n\n public CloudStoragePath toAbsolutePath()\n\nChanges relative path to be absolute, using [workingDirectory](/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.\n\n### toFile()\n\n public File toFile()\n\nThrows [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) because Google Cloud Storage files are not backed\nby the local file system.\n\n### toRealPath(LinkOption\\[\\] options)\n\n public CloudStoragePath toRealPath(LinkOption[] options)\n\nReturns this path rewritten to the Cloud Storage object name that'd be used to perform i/o.\n\nThis method makes path [absolute](/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\nthe absolute path when [stripPrefixSlash](/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageConfiguration#com_google_cloud_storage_contrib_nio_CloudStorageConfiguration_stripPrefixSlash__) is\n`true`.\n\n### toString()\n\n public String toString()\n\n**Overrides** \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--)\n\n### toUri()\n\n public URI toUri()"]]