Send feedback
  
   
 
  
    
      Class CloudStoragePath (0.128.7) 
  
  
  
   
  
    
  
  
    
    
    
    
    
  Version latestkeyboard_arrow_down  
  
 
    
    
    
    
      
  
  
  
    
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 
   
  
  
  Methods
   
  bucket() 
  
  Returns the Cloud Storage bucket name being served by this file system.
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  compareTo(Path other) 
  
    
public   int   compareTo ( Path   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherPath  
     
  
  
    
      
        Returns  
      
        Type Description  
      
        int  
     
  
  endsWith(String other) 
  
    
public   boolean   endsWith ( String   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherString  
     
  
  
  endsWith(Path other) 
  
    
public   boolean   endsWith ( Path   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherPath  
     
  
  
  equals(Object other) 
  
    
public   boolean   equals ( Object   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherObject  
     
  
  
  Overrides 
  
  getFileName() 
  
    
public   CloudStoragePath   getFileName ()  
  
  getFileSystem() 
  
    
public   CloudStorageFileSystem   getFileSystem ()  
  
  getName(int index) 
  
    
public   CloudStoragePath   getName ( int   index )  
  
    
      
        Parameter  
      
        Name Description  
      
        indexint  
     
  
  
  getNameCount() 
  
    
public   int   getNameCount ()  
  
    
      
        Returns  
      
        Type Description  
      
        int  
     
  
  getParent() 
  
    
public   CloudStoragePath   getParent ()  
  
  getRoot() 
  
    
public   CloudStoragePath   getRoot ()  
  
  hashCode() 
  
  
    
      
        Returns  
      
        Type Description  
      
        int  
     
  
  Overrides 
  
  isAbsolute() 
  
    
public   boolean   isAbsolute ()  
  
  iterator() 
  
    
public   Iterator<Path>   iterator ()  
  
  normalize() 
  
    
public   CloudStoragePath   normalize ()  
  Returns path without extra slashes or . and .. and preserves trailing slash.
register(WatchService watcher, WatchEvent.Kind<?>[] events) 
  
    
public   WatchKey   register ( WatchService   watcher ,   WatchEvent . Kind <?>[]   events )  
  
  
  
  register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier[] modifiers) 
  
    
public   WatchKey   register ( WatchService   watcher ,   WatchEvent . Kind <?>[]   events ,   WatchEvent . Modifier []   modifiers )  
  
  
    
      
        Parameters  
      
        Name Description  
      
        watcherWatchService  
      
        eventsKind <? >[] 
      
        modifiersjava.nio.file.WatchEvent.Modifier [] 
     
  
  
  relativize(Path object) 
  
    
public   CloudStoragePath   relativize ( Path   object )  
  
    
      
        Parameter  
      
        Name Description  
      
        objectPath  
     
  
  
  resolve(String other) 
  
    
public   CloudStoragePath   resolve ( String   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherString  
     
  
  
  resolve(Path object) 
  
    
public   CloudStoragePath   resolve ( Path   object )  
  
    
      
        Parameter  
      
        Name Description  
      
        objectPath  
     
  
  
  resolveSibling(String other) 
  
    
public   CloudStoragePath   resolveSibling ( String   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherString  
     
  
  
  resolveSibling(Path other) 
  
    
public   CloudStoragePath   resolveSibling ( Path   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherPath  
     
  
  
  startsWith(String other) 
  
    
public   boolean   startsWith ( String   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherString  
     
  
  
  startsWith(Path other) 
  
    
public   boolean   startsWith ( Path   other )  
  
    
      
        Parameter  
      
        Name Description  
      
        otherPath  
     
  
  
  subpath(int beginIndex, int endIndex) 
  
    
public   CloudStoragePath   subpath ( int   beginIndex ,   int   endIndex )  
  
    
      
        Parameters  
      
        Name Description  
      
        beginIndexint  
      
        endIndexint  
     
  
  
  toAbsolutePath() 
  
    
public   CloudStoragePath   toAbsolutePath ()  
  
  
  toFile() 
  
  
  
    
      
        Returns  
      
        Type Description  
      
        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  
      
        Name Description  
      
        optionsjava.nio.file.LinkOption [] 
     
  
  
  toString() 
  
  
    
      
        Returns  
      
        Type Description  
      
        String  
     
  
  Overrides 
  
  toUri() 
  
  
    
      
        Returns  
      
        Type Description  
      
        URI  
     
  
 
     
    
  
  
  
     
  
    
    
      
       
         
  
  
    
    Send feedback
  
   
 
       
    
    
  
  
 
  Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
  Last updated 2025-10-29 UTC.
 
 
  
  
    
    
    
      
  
  
    Need to tell us more?
  
   
 
     
  
  
    
      [[["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-10-29 UTC."],[],[]]