# Class CloudStorageFileSystem (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 CloudStorageFileSystem extends FileSystem

Google Cloud Storage [FileSystem](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html) implementation.
See Also: [Concepts and Terminology](https://developers.google.com/storage/docs/concepts-techniques#concepts), [Bucket and Object Naming Guidelines](https://developers.google.com/storage/docs/bucketnaming)

## Inheritance

[Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \> [FileSystem](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html) \> CloudStorageFileSystem

## 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-) [FileSystem.close()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#close--) [FileSystem.getFileStores()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getFileStores--) [FileSystem.getPath(String,String)](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPath-java.lang.String-java.lang.String...-) [FileSystem.getPathMatcher(String)](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-) [FileSystem.getRootDirectories()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getRootDirectories--) [FileSystem.getSeparator()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getSeparator--) [FileSystem.getUserPrincipalLookupService()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getUserPrincipalLookupService--) [FileSystem.isOpen()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#isOpen--) [FileSystem.isReadOnly()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#isReadOnly--) [FileSystem.newWatchService()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#newWatchService--) [FileSystem.provider()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#provider--) [FileSystem.supportedFileAttributeViews()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#supportedFileAttributeViews--)

## Static Fields

### BASIC_VIEW

    public static final String BASIC_VIEW

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

### BLOCK_SIZE_DEFAULT

    public static final int BLOCK_SIZE_DEFAULT

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

### FILE_TIME_UNKNOWN

    public static final FileTime FILE_TIME_UNKNOWN

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/FileTime.html` |   |

### GCS_VIEW

    public static final String GCS_VIEW

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

### POSIX_VIEW

    public static final String POSIX_VIEW

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

### SUPPORTED_VIEWS

    public static final Set<String> SUPPORTED_VIEWS

| **Field Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/util/Set.html<https://docs.oracle.com/javase/8/docs/api/java/lang/String.html>` |   |

### URI_SCHEME

    public static final String URI_SCHEME

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

## Static Methods

### forBucket(String bucket)

    public static CloudStorageFileSystem forBucket(String bucket)

Returns Google Cloud Storage [FileSystem](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html) object for `bucket`.

**NOTE:** You may prefer to use Java's standard API instead:


     FileSystem fs = FileSystems.getFileSystem(URI.create("gs://bucket"));
     
However some systems and build environments might be flaky when it comes to Java SPI. This
is because services are generally runtime dependencies and depend on a META-INF file being
present in your jar (generated by Google Auto at compile-time). In such cases, this method
provides a simpler alternative.
See Also: [#forBucket(String, CloudStorageConfiguration)](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystem#com_google_cloud_storage_contrib_nio_CloudStorageFileSystem_forBucket_java_lang_String_com_google_cloud_storage_contrib_nio_CloudStorageConfiguration_), java.nio.file.FileSystems#getFileSystem(java.net.URI)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `bucket` | `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.CloudStorageFileSystem` |   |

### forBucket(String bucket, CloudStorageConfiguration config)

    public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config)

Creates new file system instance for `bucket`, with customizable settings.
See Also: [#forBucket(String)](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystem#com_google_cloud_storage_contrib_nio_CloudStorageFileSystem_forBucket_java_lang_String_)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `bucket` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `config` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageConfiguration` |

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

### forBucket(String bucket, CloudStorageConfiguration config, StorageOptions storageOptions)

    public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config, StorageOptions storageOptions)

Returns Google Cloud Storage [FileSystem](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html) object for `bucket`.

Google Cloud Storage file system objects are basically free. You can create as many as you
want, even if you have multiple instances for the same bucket. There's no actual system
resources associated with this object. Therefore calling [#close()](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystem#com_google_cloud_storage_contrib_nio_CloudStorageFileSystem_close__) on the returned value
is optional.

**Note:** It is also possible to instantiate this class via Java's `
FileSystems.getFileSystem(URI.create("gs://bucket"))`. We discourage you from using that if
possible, for the reasons documented in [CloudStorageFileSystemProvider#newFileSystem(URI, java.util.Map)](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider#com_google_cloud_storage_contrib_nio_CloudStorageFileSystemProvider_newFileSystem_)
See Also: java.nio.file.FileSystems#getFileSystem(URI)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `bucket` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `config` | `https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageConfiguration` |
| `storageOptions` | `com.google.cloud.storage.StorageOptions` |

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

### listBuckets(String project, Storage.BucketListOption\[\] options)

    public static Page<Bucket> listBuckets(String project, Storage.BucketListOption[] options)

Lists the project's buckets. Pass "null" to use the default project.

Example of listing buckets, specifying the page size and a name prefix.


     String prefix = "bucket_";
     Page<Bucket> buckets = CloudStorageFileSystem.listBuckets("my-project", BucketListOption.prefix(prefix));
     Iterator<Bucket> bucketIterator = buckets.iterateAll();
     while (bucketIterator.hasNext()) {
       Bucket bucket = bucketIterator.next();
       // do something with the bucket
     }
     
| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `project` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `options` | `com.google.cloud.storage.Storage.BucketListOption[]` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.paging.Page.html<com.google.cloud.storage.Bucket>` |   |

## Methods

### bucket()

    public String bucket()

Returns 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` |   |

### close()

    public void close()

Does nothing currently. This method *might* be updated in the future to close all channels
associated with this file system object. However it's unlikely that even then, calling this
method will become mandatory.
**Overrides** [FileSystem.close()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#close--)

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

### config()

    public CloudStorageConfiguration config()

Returns configuration object for this file system instance.

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

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

### getFileStores()

    public Iterable<FileStore> getFileStores()

Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or
anything similar.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html<https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileStore.html>` |   |

**Overrides** [FileSystem.getFileStores()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getFileStores--)

### getPath(String first, String\[\] more)

    public CloudStoragePath getPath(String first, String[] more)

Converts Cloud Storage object name to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `first` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `more` | `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` |   |

**Overrides** [FileSystem.getPath(String,String)](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPath-java.lang.String-java.lang.String...-)

### getPathMatcher(String syntaxAndPattern)

    public PathMatcher getPathMatcher(String syntaxAndPattern)

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

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

**Overrides** [FileSystem.getPathMatcher(String)](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-)

### getRootDirectories()

    public Iterable<Path> getRootDirectories()

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

**Overrides** [FileSystem.getRootDirectories()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getRootDirectories--)

### getSeparator()

    public String getSeparator()

Returns {@value UnixPath#SEPARATOR}.

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

**Overrides** [FileSystem.getSeparator()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getSeparator--)

### getUserPrincipalLookupService()

    public UserPrincipalLookupService getUserPrincipalLookupService()

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

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

**Overrides** [FileSystem.getUserPrincipalLookupService()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getUserPrincipalLookupService--)

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

### isOpen()

    public boolean isOpen()

Returns `true`, even if you previously called the [#close()](https://docs.cloud.google.com/java/docs/reference/google-cloud-nio/latest/com.google.cloud.storage.contrib.nio.CloudStorageFileSystem#com_google_cloud_storage_contrib_nio_CloudStorageFileSystem_close__) method.

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

**Overrides** [FileSystem.isOpen()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#isOpen--)

### isReadOnly()

    public boolean isReadOnly()

Returns `false`.

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

**Overrides** [FileSystem.isReadOnly()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#isReadOnly--)

### newWatchService()

    public WatchService newWatchService()

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

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

**Overrides** [FileSystem.newWatchService()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#newWatchService--)

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

### provider()

    public CloudStorageFileSystemProvider provider()

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

**Overrides** [FileSystem.provider()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#provider--)

### supportedFileAttributeViews()

    public Set<String> supportedFileAttributeViews()

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

**Overrides** [FileSystem.supportedFileAttributeViews()](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#supportedFileAttributeViews--)

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